Skip to content

Conversation

@fanatic75
Copy link
Contributor

@fanatic75 fanatic75 commented Jul 13, 2023

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

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@fanatic75 fanatic75 requested a review from stnguyen90 July 13, 2023 17:47
}

$data = \array_merge($document->getArrayCopy(), $data); // Merge existing data with new data
$data['$collection'] = $collection->getId(); // Make sure user doesn't switch collectionID
Copy link
Member

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?

);
} else {
$checkPermissions($collection, $newDocument, $document, Database::PERMISSION_UPDATE);
;
Copy link
Member

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);
;
}

Copy link
Member

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
{

Copy link
Member

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'];

Copy link
Member

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);

Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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

Comment on lines +3361 to +3363
$relation->removeAttribute('$collectionId');
$relation->removeAttribute('$databaseId');
$relation->setAttribute('$collection', $relatedCollection->getId());
Copy link
Member

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

Comment on lines +3393 to +3395
$newDocument->removeAttribute('$collectionId');
$newDocument->removeAttribute('$databaseId');
$newDocument->setAttribute('$collection', $collection->getId());
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: Nested update, permission issue

4 participants