summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2018-05-18 08:22:53 (GMT)
committerAlex Pott2018-05-18 08:22:53 (GMT)
commitd6f7a9cd687a99f10dfb4cd3fd60618bfcbfaef7 (patch)
treee05cb5599bd1e9775d34100686cdb4a879e6985f
parentc44d82df1597ba754ee85f210a17e1e11b08bbe5 (diff)
Issue #2973347 by Wim Leers: EntityCreateAccessCheck should provide a useful error message when no bundle is specified
-rw-r--r--core/lib/Drupal/Core/Entity/EntityCreateAccessCheck.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php3
2 files changed, 4 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Entity/EntityCreateAccessCheck.php b/core/lib/Drupal/Core/Entity/EntityCreateAccessCheck.php
index 9ceac52..b3c12a8 100644
--- a/core/lib/Drupal/Core/Entity/EntityCreateAccessCheck.php
+++ b/core/lib/Drupal/Core/Entity/EntityCreateAccessCheck.php
@@ -62,7 +62,7 @@ class EntityCreateAccessCheck implements AccessInterface {
}
// If we were unable to replace all placeholders, deny access.
if (strpos($bundle, '{') !== FALSE) {
- return AccessResult::neutral();
+ return AccessResult::neutral(sprintf("Could not find '%s' request argument, therefore cannot check create access.", $bundle));
}
}
return $this->entityManager->getAccessControlHandler($entity_type)->createAccess($bundle, $account, [], TRUE);
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php
index 2c3d132..59f83af 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php
@@ -74,6 +74,9 @@ class EntityCreateAccessCheckTest extends UnitTestCase {
if ($expect_permission_context) {
$expected_access_result->cachePerPermissions();
}
+ if (!$entity_bundle && !$expect_permission_context) {
+ $expected_access_result->setReason("Could not find '{bundle_argument}' request argument, therefore cannot check create access.");
+ }
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');