Skip to content
Snippets Groups Projects
Verified Commit 99c6cfcc authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3035980 by jhedstrom: Provide a better error when a NULL is passed to...

Issue #3035980 by jhedstrom: Provide a better error when a NULL is passed to EntityStorageBase::load()

(cherry picked from commit 4dfdaaed)
parent 13cc9de9
No related branches found
No related tags found
No related merge requests found
......@@ -246,6 +246,7 @@ protected function doCreate(array $values) {
* {@inheritdoc}
*/
public function load($id) {
assert(!is_null($id), 'Cannot load a NULL ID.');
$entities = $this->loadMultiple([$id]);
return isset($entities[$id]) ? $entities[$id] : NULL;
}
......
......@@ -559,6 +559,9 @@ public function testLoad() {
$entity = $this->entityStorage->load('foo');
$this->assertInstanceOf(EntityInterface::class, $entity);
$this->assertSame('foo', $entity->id());
$this->setExpectedException(\AssertionError::class, 'Cannot load a NULL ID.');
$this->entityStorage->load(NULL);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment