-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix 5404 update doc without relation permission #5815
Conversation
…x-5404-update-doc-without-relation-permission
@@ -3280,7 +3276,6 @@ function updateAttribute( | |||
} | |||
|
|||
$data = \array_merge($document->getArrayCopy(), $data); // Merge existing data with new data | |||
$data['$collection'] = $collection->getId(); // Make sure user doesn't switch collectionID |
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.
Do we need to remove this?
$checkPermissions($collection, $newDocument, $document, Database::PERMISSION_UPDATE); | ||
; |
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.
Let's remove this
$checkPermissions($collection, $newDocument, $document, Database::PERMISSION_UPDATE); | ||
; | ||
} | ||
|
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.
Let's keep just one line between code blocks
|
||
public function testUpdateWithoutRelationPermission(): void | ||
{ | ||
|
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.
Let's have no blank lines at the start of function
]); | ||
|
||
$databaseId = $database['body']['$id']; | ||
|
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.
Let's keep just one line between code blocks
]); | ||
|
||
\sleep(3); | ||
|
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.
Let's keep just one blank line between code blocks
'permissions' => [], | ||
]); | ||
|
||
\sleep(3); |
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.
Let's remove this too
]); | ||
$this->assertEquals(201, $parentDocument['headers']['status-code']); | ||
|
||
\sleep(3); |
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.
Let's remove this too
$relation->removeAttribute('$collectionId'); | ||
$relation->removeAttribute('$databaseId'); | ||
$relation->setAttribute('$collection', $relatedCollection->getId()); |
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 we can do this outside the foreach loop
$newDocument->removeAttribute('$collectionId'); | ||
$newDocument->removeAttribute('$databaseId'); | ||
$newDocument->setAttribute('$collection', $collection->getId()); |
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 we can do this outside the foreach loop
What does this PR do?
Fixes #5404 Update of document with relations without permissions of relation collection
Test Plan
Added E2E test case
Related PRs and Issues
Checklist