Convert patch to MR.
Closes #2918231
Merge request reports
Activity
54 54 [$entity_type, $bundle] = explode(':', $route->getRequirement($this->requirementsKey) . ':'); 55 55 56 56 // For an entity type that has bundles, the $bundle must be specified. 57 if (empty($bundle) && $this->entityTypeManager->getDefinition($entity_type)->hasKey('bundle')) { 57 $entity_type_definition = $this->entityTypeManager->getDefinition($entity_type); @thomas.fleming Why you checked for
$this->entityTypeManager->getDefinition()
not returning NULL? Since the optional parameter$exception_on_invalid
is TRUE by default, an exception will be thrown in that case. A null pointer will never happen.Hey @vidorado probably irrelevant at this point, and apologize for not including better info on my reasoning for this. IIRC I added this check to ensure that the more helpful exception in EntityCreateAccessCheck was thrown when the replication steps were followed. Otherwise, you get the plugin not found exception, which seems out of context given the replication steps.
Hi @thomas.fleming!
This is the modified code snippet:
$entity_type_definition = $this->entityTypeManager->getDefinition($entity_type); if (empty($bundle) && $entity_type_definition && $entity_type_definition->hasKey('bundle')) { throw new \Exception("The _entity_create_access route access requires a bundle parameter because the $entity_type entity type uses bundles."); }
All you added is a local var
$entity_type_definition
in order to be able to check it just in the if() below. But, as I see,$entity_type_definition
will never be falsy at this point, since$this->entityTypeManager->getDefinition($entity_type)
will throw aPluginNotFoundException
exception if the$entity_type
is invalid.As I see, you guard won't prevent
PluginNotFoundException
to be thrown, so I believe this change is not neccessary.Do you agree with me, and don't mind if I revert it, in that case?
Thanks in advance!
Edited by Víctor Dorado
added 1110 commits
-
048d6057...de85d081 - 1107 commits from branch
project:11.x
- 26cab8cf - Convert patch to MR.
- 3fca1dd6 - Update file EntityCreateAccessCheck.php
- 97b5e5ca - Ensure an exception is thrown when no bundle is specified
Toggle commit list-
048d6057...de85d081 - 1107 commits from branch
added 1 commit
- 9137bfce - Ensure an exception is thrown when no bundle is specified