Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
entity system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 Sep 2018 at 20:12 UTC
Updated:
11 Oct 2018 at 16:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mile23After a slack chat with @berdir, I'm marking tests that touch the entity_test_revlog module as belonging to @group legacy with @expectedDeprecation messages, since that module is designed to test the BC layer.
The rest seems to be technical debt... AFAICT centered around the entity_test module. It does not have the revision_metadata_keys section for its entity, which means it triggers these errors. However, in that same chat it was unclear whether entity_test was supposed to test the BC layer or not.
Updated https://www.drupal.org/docs/8/api/entity-api/structure-of-an-entity-anno... to show these keys.
Also, I modified the error messages to tell which entity triggered it.
So here's a patch that should fail spectacularly, and tell us which entities don't have the required annotations.
Comment #4
berdirHa, 1 test fail is your definition of a spectacular fail? ;)
Looks nice. The thing is that entity_test is a non-revisionable entity type, so it doesn't need revision metadata. And that entity type is used in dozens if not hundreds of tests and only a single one fails with deprecation messages, whch makes me wonder whether that test is doing something weird.
Looked at one of the failing test methods, it installs entity_schema_test and that has entity_schema_test_entity_type_alter() and makes the entity_test entity type, which by default is not revisionable exactly that. So we need to update that hook to also set the metadata keys an we should be done here.
Comment #5
mile23Locally it was two fails when I only ran kernel tests. So, you know... weird.
I think the behavior that
EntitySchemaTest::testEntitySchemaUpdate()is testing doesn't exist once you add the metadata keys.Interestingly, if you revert the changes to
EntitySchemaTest::updateEntityType()you get radically different outcomes. This suggests the deprecations toEntityManagerare kind of maybe not 1:1.Using entity manager:
Using the non-deprecated managers:
Comment #7
berdirThere were two problems with the changes.
a) You cleared caches on the wrong service, there are multiple places with caches that were split off from entity manager. What we need here is the entity_type.manager cache because we're changing what the entity type alter hook returns. With that fixed, there's no difference anymore on entity.manager vs. specific services.
b) The metadata needs to match the fields that actually exist. Those fields are not all required, only those that exist and in this case, entity_schema_test_entity_base_field_info() only adds the revision_log field. Having those metadata keys set to fields that didn't exist caused an exception that was caught internally but then the storage was in a messed up state. That's not pretty but it's not up to this issue to change that.
Also added a sentence about those keys to the documention page you added a @todo for and removed that again.
Comment #8
larowlanshould we be adding a link to a Change record while we're here?
Comment #9
mile23Diggit.
Added CR link for those error messages, and updated the CR with a link to the how-to docs.
Comment #11
mile23Forgot the tests. :-)
Comment #12
amateescu commentedWe usually put the class name before the variable name in inline helpers like this. Also, we're missing a
*before@var:)Are these changes really required for this patch?
Comment #13
berdir1. Yep, that line is bogus, also not necessary as you explicitly added the instanceof, that does the same for the IDE.
2. No, it's not.
Comment #14
mile23Addresses #12, #13. Reverts EntitySchemaTest.
Comment #15
amateescu commentedNice, looks ready to me :)
Comment #16
alexpottCommitted d4437e2 and pushed to 8.7.x. Thanks!