Skip to content

Commit aaff6f4

Browse files
committed
Attempt to avoid making assertions on unpublished content.
1 parent 4d321c9 commit aaff6f4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/EntityAccessHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Drupal\Core\Access\AccessResultReasonInterface;
88
use Drupal\Core\Database\Connection;
99
use Drupal\Core\Entity\EntityInterface;
10+
use Drupal\Core\Entity\EntityPublishedInterface;
1011
use Drupal\Core\Entity\EntityStorageInterface;
1112
use Drupal\Core\Entity\EntityTypeInterface;
1213
use Drupal\Core\Session\AccountInterface;
@@ -140,6 +141,9 @@ public function check(EntityInterface $entity, string $operation, AccountInterfa
140141
if (!in_array($operation, $this->ops, TRUE)) {
141142
return AccessResult::neutral("Irrelevant operation.");
142143
}
144+
if ($entity instanceof EntityPublishedInterface && !$entity->isPublished()) {
145+
return AccessResult::neutral("Hierarchical access is only concerned with published content.");
146+
}
143147

144148
return $this->doCheck($entity, $operation, $account);
145149
}

0 commit comments

Comments
 (0)