X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FEntityAccessControlHandler.php;h=0a2bb193be8d8f49ee59971ca197da34698faa72;hb=refs%2Fheads%2Fd864;hp=ac364115ebd6a2dd1637bea9f77a8bb7e1e583fb;hpb=bfbba508964731508b9bd6d5835c2edc858db95b;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php b/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php index ac364115e..0a2bb193b 100644 --- a/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php +++ b/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php @@ -158,7 +158,7 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce return AccessResult::forbidden()->addCacheableDependency($entity); } if ($admin_permission = $this->entityType->getAdminPermission()) { - return AccessResult::allowedIfHasPermission($account, $this->entityType->getAdminPermission()); + return AccessResult::allowedIfHasPermission($account, $admin_permission); } else { // No opinion. @@ -316,14 +316,18 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce $default = $items ? $items->defaultAccess($operation, $account) : AccessResult::allowed(); // Explicitly disallow changing the entity ID and entity UUID. - if ($operation === 'edit') { + $entity = $items ? $items->getEntity() : NULL; + if ($operation === 'edit' && $entity) { if ($field_definition->getName() === $this->entityType->getKey('id')) { - return $return_as_object ? AccessResult::forbidden('The entity ID cannot be changed') : FALSE; + // String IDs can be set when creating the entity. + if (!($entity->isNew() && $field_definition->getType() === 'string')) { + return $return_as_object ? AccessResult::forbidden('The entity ID cannot be changed.')->addCacheableDependency($entity) : FALSE; + } } elseif ($field_definition->getName() === $this->entityType->getKey('uuid')) { // UUIDs can be set when creating an entity. - if ($items && ($entity = $items->getEntity()) && !$entity->isNew()) { - return $return_as_object ? AccessResult::forbidden('The entity UUID cannot be changed')->addCacheableDependency($entity) : FALSE; + if (!$entity->isNew()) { + return $return_as_object ? AccessResult::forbidden('The entity UUID cannot be changed.')->addCacheableDependency($entity) : FALSE; } } }