Unverified Commit 4dfdaaed authored by larowlan's avatar larowlan
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()
parent 2adeb979
......@@ -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);
}
/**
......
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