Problem/Motivation
As of #1605290: Enable entity render caching with cache tag support, and especially now that #2099131: Use #pre_render pattern for entity render caching has landed also, the need for \Drupal\Core\Field\PrepareCacheInterface
is no more: the entire rendered output of entities is cached, which removes its need.
To quote catch from #2217877-10: Text filters should be able to add #attached, #post_render_cache, and cache tags:
It was only done for performance - i.e. to avoid 30 check_markup() cache hits when there were thirty entities rendered. But since we now cache the entire HTML, we'd not be making those cache hits all the time.
And again catch from the same issue, but comment 21:
I worked on the original patch that added the check_markup() in hook_field_load() and it was purely for optimization of content listings with lots of text fields (i.e. comments) so that they wouldn't do an extra round trip to the cache for each call to check_markup(). This is obsolete with render caching. Same for the date formats.
Only two field types used this: DateTimeItem
and TextItemBase
.
Proposed resolution
Remove \Drupal\Core\Field\PrepareCacheInterface
.
Remaining tasks
Review.
User interface changes
None.
API changes
PrepareCacheInterface
removed; it's no longer needed.
Comment | File | Size | Author |
---|---|---|---|
#19 | remove_preparecacheinterface-2274517-19.patch | 14.76 KB | Wim Leers |
Comments
Comment #1
Wim LeersComment #2
Wim LeersComment #3
BerdirSee comment ;)
=> timezone cache tag for date fields? Not a bug introduced here but as we remove that comment, we should fix that with fairly high priority?
The patch doesn't remove the code that is actually calling the getCachedData() methods in the content entity storage.
Comment #4
Wim LeersRE: timezone handling, created an issue + patch to fix that: #2274791: Rendered entities should be cached by time zone.
RE: removing the actual callers of
getCacheData()
: done.Comment #6
Wim LeersChasing HEAD; straight reroll.
Comment #7
BerdirWe only need the loop for this prepare cache check, now that this is gone, we can call $items->geValue().
Still need to figure out what to do in #597236: Add entity caching to core (I will still need a method on entities, but doesn't need to be a special interface I think).
text_filter_format_disable() and text_filter_format_update() only exist to clear the entity cache if they get disabled/changed, I assume we got that covered now with cache tags and can just remove them. Otherwise FilterSecurityTest wouldn't pass :)
I checked that we have no calls to check_markup() left on the frontpage with a bunch of nodes on a render cache hit, so this should be good to go after another round of clean-up :)
Comment #8
Wim LeersDone! :)
Comment #10
Wim LeersThis unfortunately caused those 590 fails and 296 exceptions AFAICT :(
Trying without that.
Comment #11
yched CreditAttribution: yched commented@Wim : the role of this code block remains to populate the $data array.
I think @Berdir meant
$data[$langcode][$field_name] = $items->getValue();
;-)Comment #12
Wim LeersOMG EPIC WIMFAIL Sorry!
/me blushes :P
This is #8 again, but with less epic fail. (Hopefully none.)
Comment #13
fagoI'm not so sure. What if you send out e.g. digest e-mails containing a lot of nodes including token replacements, then the cached processed text would be still useful? Or, when entities are rendered to a RESTful service? Then, the optimization seems to be still valuable?
Comment #14
Wim Leers#13: that sounds like a case of premature optimization, no? More importantly, caching it here would be the wrong place to cache it: you don't want to cache many small things, you want to cache few big things. So, IMO, the answer would be to implement smarter caching for the use cases you cite:
Comment #15
BerdirProcessed is (right now) not even printed in in the rest output because it's computed ;) and yes, that means you have read access to the raw value...
Comment #16
fagowhat's really great as this was the reason to add it as property in the first place.. :D
ad #13: good point, agreed.
Comment #18
BerdirWithout the $delta.
We're getting closer ;)
Comment #19
Wim LeersSigh. This definitely is my epic fail streak issue.
Comment #20
BerdirI think this looks good, time for @catch to have a look...
Comment #22
catchLooks good to me too, nice to see this gone.
Committed/pushed to 8.x, thanks!
Comment #23
BerdirGreat, updated https://drupal.org/node/2064123/revisions/view/7175651/7294389 and removed references to this interface and also updated the documentation page at https://drupal.org/node/2112677.