Problem/Motivation

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.

Proposed resolution

Take advantage of the fact that most bundles (seemingly all those currently defined in core) use a storage mechanism that supports the hasData() method (as specified by the DynamicallyFieldableEntityStorageInterface interface). When checking for existing entities for a given bundle, use hasData() if supported by the bundle's storage mechanism. If not, only then fall back to the current approach and attempt to build and execute an entity query.

Remaining tasks

  • Discuss alternate solutions and related issues
  • Determine whether this issue will be obviated by other ongoing work

User interface changes

None

API changes

None

CommentFileSizeAuthor
#1 2409013-1.patch2.56 KBndewhurst
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ndewhurst’s picture

FileSize
2.56 KB
ndewhurst’s picture

Issue summary: View changes
Status: Needs work » Needs review
ndewhurst’s picture

Assigned: ndewhurst » Unassigned
ndewhurst’s picture

Issue summary: View changes
chx’s picture

Why? Why don't we make hasData mandatory and add it to null storage? And it can return FALSE. It would be simpler, no?

ndewhurst’s picture

chx, that would be awesome. I confined my changes to this one spot simply because I wasn't well versed in the broader discussions/history surrounding storage. (a.k.a. I was being timid ;)

alexpott’s picture

Priority: Normal » Major
Issue tags: +Configurables, +Configuration system
alexpott’s picture

alexpott’s picture

Status: Needs review » Closed (duplicate)

Closing as a duplicate of #2337753: ContentEntityNullStorage does not implement a query service which now has a test for this specific issue.

ndewhurst’s picture

Thanks Alex - that makes sense. Just for my own understanding, does this mean another storage could come along that doesn't provide a query mechanism (and our expectation that there will always be one becomes a matter of convention)? Not that that would be a problem, especially in a controlled system. I'm mostly just trying to refresh my memory on this stuff without an active D8 site in front of me :)
I'll keep an eye on that other issue...