Currently the entities are only loaded when they are needed, which is every time a field is used, or when an edit / delete link is shown (since the entity is needed to check access). This means that the entity is loaded in almost every case.
D8 will make entities needed for properties as well (especially if you want to have properties work across query backends, which is very desirable), since they will become very field-like (and trying to avoid loading entities for fields didn't go well for us).
So, I suggest always loading entities if the tables in the query belong to entity types, which allows us to cleanup the Field API and Entity field handlers, as well as allowing further improvements (handlers for properties).
Comment | File | Size | Author |
---|---|---|---|
#15 | 1758634-load-entities.patch | 31.4 KB | bojanz |
#13 | 1758634-load-entities.patch | 35.49 KB | bojanz |
#11 | 1758634-load-entities.patch | 35.25 KB | bojanz |
#3 | 1758634-load-entities.patch | 34.44 KB | bojanz |
#9 | 1758634-load-entities.patch | 35.2 KB | bojanz |
Comments
Comment #1
tim.plunkettTagging.
Comment #2
dawehnerThe really advantage of doing that would be that we could probably get rid A LOT OF code from the field field handler
which takes care of all the loading of the entities.
Comment #3
bojanz CreditAttribution: bojanz commentedThe Field API handler is 100 lines smaller alone.
Changelog:
1) Removed get_result_entities() from the query object. Added a load_entities() method (used by the query execute(), not the handlers!) that also supports revisions (like the Field API code, unlike the old get_result_entities()). Entities are stored either in $row->_entity or $row->_relationship_entities[$relationship_id].
2) Made the base fields of all entity tables always added to the query (so that we can actually load the entities), and because of that, removed "pure distinct".
2) Removed Field API post_execute() and half of the query() code. Removed the useless "add fields to query" flag and renamed get_value to process_entity for more clarity.
3) Removed the "Entity" field handler since now all handlers have access to the entities matching the row.
4) Added a convenience get_entity() method to the base field handler (FieldHandlerBase).
Comment #4
aspilicious CreditAttribution: aspilicious commentedI'm a total noob on this but do we still need to implement the query method in "FieldPluginBase". It seems it can be removed. If thats the case you can also remove it from the classes inheriting FieldPluginBase
Comment #5
xjmBOTIFY
Comment #6
dawehnerAs we talked before, we should document what people should do if there are no entities related to the query plugin.
post_execute of the page is used by fast-pagers so let's allow them to control stuff before loading entities.
missing array
what about describing the content of the table information as well?
Just for readability we might turn around the logic in general. Most of the time people take care just about the normal entity handling.
Just in general is there any way we can document this that people are able to find that?
I'm not 100% sure about that, but it seems to be that render_link expects the cid here and get_entity returns the full objects.
Comment #7
dawehnerggr.
Comment #9
bojanz CreditAttribution: bojanz commentedAddressed the feedback.
Comment #11
bojanz CreditAttribution: bojanz commentedLet's try again with a slightly saner patch.
Comment #13
bojanz CreditAttribution: bojanz commentedPass tests, pass!
Comment #15
bojanz CreditAttribution: bojanz commentedRebased now that #1760772: Remove pure_distinct, cleanup the query assembly code was committed.
Comment #16
bojanz CreditAttribution: bojanz commentedCommitted.