Commit 49caf9de authored by alexpott's avatar alexpott

Issue #2296115 by jhodgdon, hussainweb: Fixed Several entity loadRevision()...

Issue #2296115 by jhodgdon, hussainweb: Fixed Several entity loadRevision() methods do not obey the interface contract.
parent 816c9c59
......@@ -77,8 +77,8 @@ function entity_load($entity_type, $id, $reset = FALSE) {
* @param int $revision_id
* The id of the entity to load.
*
* @return \Drupal\Core\Entity\EntityInterface
* The entity object, or FALSE if there is no entity with the given revision
* @return \Drupal\Core\Entity\EntityInterface|null
* The entity object, or NULL if there is no entity with the given revision
* id.
*
* @see \Drupal\Core\Entity\EntityManagerInterface
......
......@@ -125,10 +125,10 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
}
/**
* Implements Drupal\Core\Entity\EntityStorageInterface::loadRevision().
* {@inheritdoc}
*/
public function loadRevision($revision_id) {
return FALSE;
return NULL;
}
/**
......
......@@ -82,8 +82,8 @@ public function loadUnchanged($id);
* @param int $revision_id
* The revision id.
*
* @return \Drupal\Core\Entity\EntityInterface|false
* The specified entity revision or FALSE if not found.
* @return \Drupal\Core\Entity\EntityInterface|null
* The specified entity revision or NULL if not found.
*/
public function loadRevision($revision_id);
......
......@@ -133,7 +133,7 @@ public function doLoadMultiple(array $ids = NULL) {
* {@inheritdoc}
*/
public function loadRevision($revision_id) {
return FALSE;
return NULL;
}
/**
......
......@@ -679,7 +679,7 @@ protected function attachPropertyData(array &$entities) {
}
/**
* Implements \Drupal\Core\Entity\EntityStorageInterface::loadRevision().
* {@inheritdoc}
*/
public function loadRevision($revision_id) {
// Build and execute the query.
......@@ -690,7 +690,10 @@ public function loadRevision($revision_id) {
// Convert the raw records to entity objects.
$entities = $this->mapFromStorageRecords($records);
$this->postLoad($entities);
return reset($entities);
$entity = reset($entities);
if ($entity) {
return $entity;
}
}
}
......
......@@ -692,7 +692,7 @@ public function testLoadMultipleIds() {
* @covers ::loadRevision()
*/
public function testLoadRevision() {
$this->assertSame(FALSE, $this->entityStorage->loadRevision(1));
$this->assertSame(NULL, $this->entityStorage->loadRevision(1));
}
/**
......
......@@ -601,7 +601,7 @@ public function testLoadMultipleIds() {
public function testLoadRevision() {
$this->setUpKeyValueEntityStorage();
$this->assertSame(FALSE, $this->entityStorage->loadRevision(1));
$this->assertSame(NULL, $this->entityStorage->loadRevision(1));
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment