Loading core/lib/Drupal/Core/Access/AccessResult.php +2 −0 Original line number Diff line number Diff line Loading @@ -279,6 +279,7 @@ public function cachePerUser() { /** * {@inheritdoc} */ #[\NoDiscard] public function orIf(AccessResultInterface $other) { $merge_other = FALSE; // $other's cacheability metadata is merged if $merge_other gets set to TRUE Loading Loading @@ -340,6 +341,7 @@ public function orIf(AccessResultInterface $other) { /** * {@inheritdoc} */ #[\NoDiscard] public function andIf(AccessResultInterface $other) { // The other access result's cacheability metadata is merged if $merge_other // gets set to TRUE. It gets set to TRUE in one case: if the other access Loading core/lib/Drupal/Core/Access/AccessResultInterface.php +2 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ public function isNeutral(); * * @return static */ #[\NoDiscard] public function orIf(AccessResultInterface $other); /** Loading @@ -103,6 +104,7 @@ public function orIf(AccessResultInterface $other); * * @return static */ #[\NoDiscard] public function andIf(AccessResultInterface $other); } core/modules/media/src/MediaAccessControlHandler.php +1 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,7 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter $entity_access = $entity->access('view', $account, TRUE); if (!$entity->isDefaultRevision()) { $media_storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId()); $entity_access->andIf($this->access($media_storage->load($entity->id()), 'view', $account, TRUE)); $entity_access = $entity_access->andIf($this->access($media_storage->load($entity->id()), 'view', $account, TRUE)); } return AccessResult::allowed()->cachePerPermissions()->andIf($entity_access); Loading core/modules/media/tests/src/Functional/MediaAccessTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public function testMediaAccess(): void { $this->assertCacheContext('user'); $assert_session->statusCodeEquals(200); $this->drupalGet('media/' . $user_media->id() . '/revisions/' . $previous_revision . '/view'); $this->assertCacheContext('user.permissions'); $this->assertCacheContext('user'); $assert_session->statusCodeEquals(200); $role->revokePermission('view own unpublished media')->save(); $this->drupalGet('media/' . $user_media->id() . '/revisions/' . $user_media->getRevisionId() . '/view'); Loading Loading
core/lib/Drupal/Core/Access/AccessResult.php +2 −0 Original line number Diff line number Diff line Loading @@ -279,6 +279,7 @@ public function cachePerUser() { /** * {@inheritdoc} */ #[\NoDiscard] public function orIf(AccessResultInterface $other) { $merge_other = FALSE; // $other's cacheability metadata is merged if $merge_other gets set to TRUE Loading Loading @@ -340,6 +341,7 @@ public function orIf(AccessResultInterface $other) { /** * {@inheritdoc} */ #[\NoDiscard] public function andIf(AccessResultInterface $other) { // The other access result's cacheability metadata is merged if $merge_other // gets set to TRUE. It gets set to TRUE in one case: if the other access Loading
core/lib/Drupal/Core/Access/AccessResultInterface.php +2 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ public function isNeutral(); * * @return static */ #[\NoDiscard] public function orIf(AccessResultInterface $other); /** Loading @@ -103,6 +104,7 @@ public function orIf(AccessResultInterface $other); * * @return static */ #[\NoDiscard] public function andIf(AccessResultInterface $other); }
core/modules/media/src/MediaAccessControlHandler.php +1 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,7 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter $entity_access = $entity->access('view', $account, TRUE); if (!$entity->isDefaultRevision()) { $media_storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId()); $entity_access->andIf($this->access($media_storage->load($entity->id()), 'view', $account, TRUE)); $entity_access = $entity_access->andIf($this->access($media_storage->load($entity->id()), 'view', $account, TRUE)); } return AccessResult::allowed()->cachePerPermissions()->andIf($entity_access); Loading
core/modules/media/tests/src/Functional/MediaAccessTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -132,7 +132,7 @@ public function testMediaAccess(): void { $this->assertCacheContext('user'); $assert_session->statusCodeEquals(200); $this->drupalGet('media/' . $user_media->id() . '/revisions/' . $previous_revision . '/view'); $this->assertCacheContext('user.permissions'); $this->assertCacheContext('user'); $assert_session->statusCodeEquals(200); $role->revokePermission('view own unpublished media')->save(); $this->drupalGet('media/' . $user_media->id() . '/revisions/' . $user_media->getRevisionId() . '/view'); Loading