Needs work
Project:
Drupal core
Version:
main
Component:
entity system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Apr 2018 at 20:53 UTC
Updated:
7 Jan 2019 at 16:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
berdirFixed test fails and removed a few more tables.
Did not yet remove any non-test entity types or entity types from entity_test_revlog as I'm not quite sure how this is affects updates.
Comment #3
berdirMessed up and mixed this with a datetime patch, hopefully removed all unrelated changes.
This was a good one.
Those test entity types didn't have unique entity tables before and we still silently skip already existing tables when installing entity types, so the test here worked even though it didn't create the entity schema for that entity type.
Comment #4
amateescu commentedI'm aiming for the nitpick of the month award, so..
Extra empty line here :)
Also, I would add a @todo that points to #2232465: Deprecate table names from entity definitions because the default table names will most likely be generated by the default table mapping, not by
ContentEntityType.Comment #5
chanderbhushan commentedHi, tested #3 patch is working fine. thanks
Comment #6
berdirComment #8
andypostReroll & removed table name generation cos table mapping already does the same
Comment #10
andypost@amateescu Does #4 means that
$entityType->getBaseTable()should proxy call to table mapping?Comment #11
berdirAs you can see with the amount of fails you get, we can't remove this yet., I don't think we can proxy to the table mapping, as that's a) storage specific and b) would most likely result in a recursion.
I discussed this with @amateescu a while ago but don't sure if I remember correctly, but IMHO doing this would b a step forward towards consistent table names (those test entity types are really bad examples right now). Then we'll have to move those method calls to the table mapping, deprecate them on the entity type and eventually remove.
Comment #12
hchonovRe#3:
I like that, a lot!
For this we still need a dedicated issue, right?
Comment #14
tstoecklerI think we should proceed with #3 as a step forward. It both allows to clean up some lines in the test modules, fixes a bug in the entity test classes and more importantly allows contrib to remove some more boilerplate from their entity types which is always nice. Consolidating this code with the respective one in the table mapping is then only internal cleanup which is transparent to contrib.
Re #12: Since it's only a problem in test modules and not a functional bug for any actual Drupal site out there, I think it is fine to fix this bug as part of this task. I see it as validation that the patch works as intended. Speaking of validation I was wondering whether we need unit test coverage of this, but we currently don't have a unit test for
ContentEntityTypeand it's arguable whether there should be one because it's mostly just a value-object (but for little niceties like the one introduced here), so I think we're good. By removing the annotation entries from the various test entities we already have ample functional test coverage.I have one remaining question and one tiny nitpick when looking at #3.
It has always bothered me that we - when we initially introduced those defaults in the storage (which are now in the table mapping) that we fall back to the entity type ID as the prefix instead of the base table. If you don't specify any tables it ends up being the same, but it would be nice if - if you were unhappy with the entity type ID as the base table name - could specify an alternate base table and all the other table names would follow suit and use the same prefix. Right now this leads to a very confusing table list. We have a similar issue with dedicated field tables, which always use the entity type ID as the prefix, and which is why I became aware of this issue because that latter point leads to the annoying prefix difference in the user entity tables. Because the user entity uses "users" instead of "user" as a prefix (because
USERis a reserved word in MySQL) we have a "users_field_data" table but auser__rolestable even though they both belong to the same entity type.The question is whether this would somehow affect backwards-compatibility in which case it would make sense to just live with the way it currently is, but I'm not sure, because this is entirely new code at least in this class, so I thought I'd bring it up.
Unnecessary newline