Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 58
Same twoWayKey#327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Same twoWayKey #327
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1537,11 +1537,15 @@ public function createRelationship( | ||||||||||||||||||||||||||||||||||
| throw new DuplicateException('Attribute already exists'); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| if ($attribute->getAttribute('type') === self::VAR_RELATIONSHIP | ||||||||||||||||||||||||||||||||||
| && \strtolower($attribute->getAttribute('options')['twoWayKey']) === \strtolower($twoWayKey) | ||||||||||||||||||||||||||||||||||
| && $attribute->getAttribute('options')['relatedCollection'] === $relatedCollection->getId() | ||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||
| throw new DuplicateException('Related attribute already exists'); | ||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||
| if ($attribute->getAttribute('type') === self::VAR_RELATIONSHIP | ||||||||||||||||||||||||||||||||||
| && \strtolower($attribute->getAttribute('options')['twoWayKey']) === \strtolower($twoWayKey) | ||||||||||||||||||||||||||||||||||
| && $attribute->getAttribute('options')['relatedCollection'] === $relatedCollection->getId() | ||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||
| throw new DuplicateException('Related attribute already exists'); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } catch (DuplicateException $e) { | ||||||||||||||||||||||||||||||||||
| $twoWayKey ??= $collection->getId() . '_' . uniqid(); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
Comment on lines
+1540
to
1549
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need a try/catch here, we can use use the if:
Suggested change
| ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
$twoWayKey = $collection->getId() . '_' . uniqid();, otherwise it will only assign if null