Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
entity system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 May 2016 at 20:07 UTC
Updated:
19 Feb 2019 at 12:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
marvin_b8 commentedComment #4
valthebaldComment #6
rajeshwari10 commentedAdding patch.
Comment #8
valthebaldThe reason for AmbiguousEntityClassException for Drupal\config_test\Entity\ConfigTest class is config_test_entity_info_alter() hook. This hook clones config_test entity type to config_test_mul, config_test_rev, and config_test_mul_rev. All cloned entity types inherit the same controller class ConfigTest.
I am not sure what's the correct way to solve this test failure. Is one-to-one relation between entity type and controller the correct assumption? If yes, should hook_entity_info_alter() invocation check for cloned entity types having the same controller? If no, test should not throw AmbiguousEntityClassException
Comment #9
valthebaldComment #10
mile23Comment #11
chishah92 commentedRerolled.
~Chirag
Comment #13
mile23Patch applies to 8.3.x. Superficially removes all calls to
entity_load('config_test').Re-running tests to see if they magically pass.
Un-assigning chishah92. Please re-assign yourself if you'd like.
Comment #15
daffie commentedHopefully this will fix all the testbot errors.
Comment #16
valthebaldApplied the patch from #15 to the latest 8.3.x - this removes all occurences of (regex search)
entity_load.*'config_testComment #17
alexpottThis is changing the test - it did not do a reset before why now? It is wrong to change what is tested in these patches.
Comment #20
mile23Patch no longer applies.
Comment #21
jofitzRe-rolled.
Comment #22
jofitzRemoved calls to
$storage->resetCache(), as per @alexpott's comments in #17.Although it should be noted that the same method has been accepted into core in Drupal\Tests\config\Functional\ConfigOtherModuleTest::testUninstall().
Comment #25
jofitzEntity->load() returns NULL (not FALSE) when an entity is not found.
Comment #28
jacobsanford@Jo Fitzgerald's patch in #25 no longer applied to 8.6.x. A reroll with no further modifications is attached.
Comment #30
jofitzCompared the patch with the patch in #15 and it looks like I made a mistake in my re-roll in #21.
Comment #32
jofitzFailure appears to have been a testbot bug.
Comment #33
mile23OK, so the function signature of
entity_load()looks like this:If
$resetisFALSE(which it is by default), then our modifications shouldn't reset the cache, like @alexpott points out in #17.However, If
$resetisTRUE, then the changes should reset the cache in order to be like the original test code.So please reset the cache for the tests with
TRUEpassed in for$reset.Comment #34
jofitzRe-instate the cache resets removed in error.
Comment #36
mile23No longer applies.
Comment #37
savkaviktor16@gmail.com commentedRe-rolled
Comment #38
alexpottLet's rescope this issue into something that will eventually deliver the same change but do so in a way that means we won't add anymore usages in. See https://www.drupal.org/core/scope for why the current scope doesn't really work. So let's scope this to deal with properly deprecating entity_load()
Comment #39
alexpottPatch replaces all entity_load() calls in core.
Comment #40
berdirI think we pretty much agreed on not using $this->container anymore in tests? Update to \Drupal:entityTypeManager()?
quite a few more of these below.
config_test doesn't use a static cache, so those resetCache() calls shouldn't be needed and if we really want to keep them then we could do a single resetCache() without arguments first, should make this more readable again? Like we actually do below on the last call..
Comment #41
alexpott@Berdir good points - patch addresses them.
Comment #43
berdiranother $this->container, this is a kernel test, so this definitely doesn't require a cache clear either.
(Btw, I had the idea to open an issue to reset the global entity static cache service after POST requests, just like we reset config and other things.. that would probably remove about 90% of the cases where we need resetCache() in tests..)
I guess this is the one that fails, $storage probably doesn't exist here? or dies it above?
another kernel tes twith resetCache(), only reason it would be required is if we'd somehow change the stored data by hand above, but it looks like a regular save based on the visible context.
Comment #44
alexpott1. Fixed
2. $storage is defined above
3. It doing this in
foreach (entity_test_entity_types(ENTITY_TEST_TYPES_REVISABLE) as $entity_type) {I guess we can swap to loadUnchanged() and then we have to think about but we know we're dealing with what is in the DB. I guess we could use loadUnchanged() in a couple of other places - ie after// Ensure that the config entity was not corrupted.Comment #45
berdirLooks good, just needs an explicit deprecation test and this should be done. Unless we also want to deprecate node_load() and user_load() which both are usage-free in core so they'd be easy. Found editor_load() as a somewhat strange case that still has a few usages.
Comment #46
alexpottI think as node_load() and user_load() are not in entity.inc and have no usages they are outside this scope. We can do them in yet-another-issue.
Added a test.
Comment #47
berdirWorks for me, just mentioned that because that's what you did with the _load_multiple() functions :)
Comment #48
alexpott@Berdir good point - well made :)
Comment #50
alexpottI think as editor_load() has usages, is a bit different and is not deprecated we shouldn't touch it here. Done the reset and added tests.
Comment #51
alexpottMissed some... even test entity types have load functions! Deprecated them for good measure but didn't add tests of the test functions.
Comment #52
berdirhm, the file load functions recommend File::load*() while the others recommend the entity storage load method.
oh well, so does node_load() and many others. I guess the argument is that an entity_load() was likely dynamic and couldn't be hardcoded like that.
I think it would have been OK to just remove those :)
Looks good to me.
Comment #53
catchCommitted a3a1663 and pushed to 8.7.x. Thanks!