reverted: --- b/core/lib/Drupal/Core/Entity/EntityManager.php +++ a/core/lib/Drupal/Core/Entity/EntityManager.php @@ -9,7 +9,6 @@ use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Component\Plugin\Exception\PluginNotFoundException; -use Drupal\Component\Uuid\Uuid; use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; @@ -969,10 +968,6 @@ * {@inheritdoc} */ public function loadEntityByUuid($entity_type_id, $uuid) { - // Return NULL for invalid UUID's. - if (empty($uuid) || !Uuid::isValid($uuid)) { - return NULL; - } $entity_type = $this->getDefinition($entity_type_id); if (!$uuid_key = $entity_type->getKey('uuid')) { @@ -981,10 +976,6 @@ $entities = $this->getStorage($entity_type_id)->loadByProperties(array($uuid_key => $uuid)); - if (!reset($entities)) { - return NULL; - } - return reset($entities); } only in patch2: unchanged: --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -1545,6 +1545,37 @@ protected function getTestHandlerClass() { return get_class($this->getMockForAbstractClass('Drupal\Core\Entity\EntityHandlerBase')); } + /** + * Tests the loadEntityByUuid() method. + * + * @covers ::loadEntityByUuid() + * + * @dataProvider providerTestLoadEntityByUuid + */ + public function testloadEntityByUuid($entity_type_id, $uuid) { + $entity = $this->getMock('Drupal\Core\Entity\EntityManager'); + $this->setUpEntityManager(array( + 'apple' => $entity, + 'banana' => $entity, + )); + + $new_entity = $this->entityManager->loadEntityByUuid($entity_type_id,$uuid); + $this->assertNull($new_entity); + } + + /** + * Provides test data for testloadEntityByUuid(). + * + * @return array + * Test data. + */ + public function providerTestLoadEntityByUuid() { + return array( + array('apple', 2415), + array('banana', NULL), + ); + } + } /*