Closed (fixed)
Project:
Drupal core
Version:
8.4.x-dev
Component:
entity system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Dec 2014 at 17:37 UTC
Updated:
29 Sep 2017 at 11:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
fagoComment #2
cilefen commentedComment #4
cilefen commentedComment #5
plachWay better :)
Can we add an implementation for
ContentEntityNullStorage?Comment #6
cilefen commented@plach There already is one without this patch.
Comment #7
plachMmh, I should really get some rest. This looks ready to me :)
Comment #8
plachWould it make sense to return this?
I'm wondering whether it could imply performance problems.
Comment #9
berdirPossibly. The query implementation also uses getAll(), there is nothing else that we could use.
It's just a test implementation really, I hope nobody is going to use it for real data :)
Comment #10
yched commentedYay - looks good indeed ?
Comment #11
fagoWhy that? It should just run an entity query as for content entities + we need test coverage that hasData() works for for config entities.
Comment #12
yched commentedAs a side note : #2392351: When an entity bundle config gets deleted, entities of that bundle break has a case for "are there existing entities *for that specific bundle* ?", and curently has to include dedicated code that almost duplicates ContentEntityStorage::hasData(), just adding an extra
->condition($entity_type->getKey('bundle'), $bundle)Would be a nice thing to add as an optional param in ContentEntityStorage::hasData() ?
Comment #13
yched commentedAnd right, having the implemtation always returning FALSE for ConfigEntityStorage & KeyValueEntityStorage is a bit problematic.
- KeyValueEntityStorage would need to return
count($this->keyValueStore->getAll()) != 0Although, yeah, as mentioned above, that is kind of a perf drag :-/
From @Berdir #9:
OK, but nothing really hints that it's a test-only-do-not-use-for-real implementation :-).
It's not in a "test" directory or namespace, Drupal\Core\Entity\KeyValueStore makes it kind of "officially endorsed", and no comment or phpdoc say anything about that either.
So maybe the we should go with the getAll() approach for now, and open a separate issue to move that class to a test folder somewhere ?
- ConfigEntityStorage would need to return
count($this->configFactory->listAll()) != 0That's not as bad as KV::getAll(), since this only load keys into memory. Could still be 100's of entries just to answer "is there at least one ?". Making that more efficient means adding a new method to ConfigFactoryInterface & Config\StorageInterface, though.
Comment #14
berdir/me points to @timplunkett ;)
I know and I'd be happy to do that.
Comment #15
yched commentedOpened #2393751: Document that KeyValueEntityStorage is not scalable beyond a few hundred entities :-)
Comment #16
berdirOk, here's a patch with implementation for config and keyvalue. I also added a test, this also runs for key value storage.
Comment #17
plachComment #18
plachComment #21
cilefen commentedreroll
Comment #22
cilefen commentedoops
Comment #25
cilefen commentedI think this test is failing because the config_test module sets some configurations objects on install.
Comment #31
amateescu commented#25 is correct, so we simply need to move those assertions to a test that doesn't install config_test entities by default. And, since KeyValueEntityStorage is not used as a test config storage anymore, we need to add a dedicated test for that as well.
Comment #32
amateescu commentedAnd to show why this is still a major bug, I've added a simple test that tries to see if uninstalling a module which provides an entity type that doesn't use the SQL content entity storage is possible.
This simulates a user navigating to the module uninstall page and being presented with a nice fatal error:
The test-only patch is also the interdiff.
Comment #33
amateescu commentedComment #35
berdirPatch looks good to me, but not sure if adding a method to EntityStorageInterface now is a BC break, since there is no default implemtentation then it would break alternative entity storage implementations. So possibly we need a separate interface now, with a @todo to merge it into the base interface in 9.x?
Comment #36
berdirdouble post because of 5xx error
Comment #37
amateescu commented@Berdir, isn't
\Drupal\Core\Entity\EntityStorageBasethe default implementation? We could move\Drupal\Core\Entity\ContentEntityStorageBase::hasData()toEntityStorageBasebecause that implementation is generic and it doesn't depend on anything else but the entity query, which is initialized inEntityStorageBaseanyway.Comment #38
berdirYes, that makes sense, lets do that :)
Comment #39
amateescu commentedDone that ;)
Comment #40
berdirGreat, I think this is OK now for BC. We might still want to do a short change record?
Comment #41
amateescu commentedSure thing, here it is: https://www.drupal.org/node/2907014
Comment #42
catchCommitted/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks! Publishing the change record.