diff --git a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php index 157d79d..7fd2db5 100644 --- a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php +++ b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php @@ -65,14 +65,14 @@ public function convert($value, $definition, $name, array $defaults) { $entity_type_id = $this->getEntityTypeFromDefaults($definition, $name, $defaults); $entity = NULL; if ($storage = $this->entityManager->getStorage($entity_type_id)) { - // Load by UUID or ID depending on $value. - if (is_int($value) || ctype_digit((string) $value)) { - $entity = $storage->load($value); - } - elseif (Uuid::isValid($value)) { + // Load by UUID or ID depending on $value. Optimise skipping the UUID check and loading by UUID + if (!(is_int($value) || ctype_digit((string) $value)) && Uuid::isValid($value)) { $entities = $storage->loadByProperties(['uuid' => $value]); $entity = ($entities) ? reset($entities) : NULL; } + if (!$entity) { + $entity = $storage->load($value); + } // If the entity type is translatable, ensure we return the proper // translation object for the current context. if ($entity instanceof EntityInterface && $entity instanceof TranslatableInterface) {