Suppose you have some arbitrary $entity_type_id and you want to know if there are any entities stored. Sadly:
isn't guaranteed to work, because
ContentEntityNullStorage::getQueryServiceName() throws an exception. Another alternative is to use the countFieldData() method and count the values for the field holding the entity ID:
but that's pretty ugly and only works for fieldable entities.
This is a major bug because:
During a configuration import, the Entity system performs validation to ensure that bundles are not deleted if they are in use on the target site. The current code for this validation assumes that the storage for all validated bundles will return a usable query via the getQuery() method. However, this is not the case for bundles using ContentEntityNullStorage (which appears to be used by contact forms). Such bundles will cause a QueryException to be thrown, breaking the import process.
Option 1: Require storage handlers to always implement a working entity query service. Even for NULL storage, which can always return empty/0 as appropriate.
Option 2: Add a
hasData() method or similar to
- Improve tests
User interface changes
Suggested commit message
git commit -m 'Issue #2337753 by alexpott, ndewhurst: ContentEntityNullStorage does not implement a query service'
@ndewhurst deserves credit for their work on
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 94,526 pass(es). View
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 92,435 pass(es). View
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 92,492 pass(es), 0 fail(s), and 1 exception(s). View