As part of #2124957: Replace 'content' cache tag with 'rendered' and use it sparingly, we added extensive test coverage for the most important content entity types' usage of cache tags in #2188565: Test coverage for Comment, Custom Block, Node, Taxonomy Term and User entity cache tags.
Aggregator's Feed
and Item
are two of the three last content entity types (the last is Shortcut
) that don't yet use cache tags yet when rendering content.
#2217749: Entity base class should provide standardized cache tags and built-in invalidation added standardized cache tags to all entities, so we can use those.
Let's use those cache tags for rendered feeds/feed items and add basic test coverage.
This also allows us to cache the AggregatorFeedBlock
forever by default :)
Comment | File | Size | Author |
---|---|---|---|
#19 | oops-2241229-19.patch | 1.38 KB | Wim Leers |
Comments
Comment #1
Wim LeersComment #3
catchWhy do we have to load the items to get their tags? Shouldn't those be added when the items themselves are rendered?
Comment #4
Wim Leers#3: I was asking myself that question also. From the discussions I've had with people on the Block cache patch (#2158003: Remove Block Cache API in favor of blocks returning #cache with cache tags), the conclusion was that if at all possible, blocks should always return all the cache tags if they can.
That being said, I worked on #2241291: Regression: menu link-specific cache tags and #2241235: Shortcut/ShortcutSet entity types should use cache tags after this issue, and now I think we should get rid of the
Item
-specific cache tags, and give them the same treatment asMenuLink
: only use the higher-level cache tag (Feed
andMenu
, respectively).Comment #5
ParisLiakos CreditAttribution: ParisLiakos commentedhmm would probably be better to inject the factory instead. i find it cleaner than cloning.
/me noted it for the next time i inject entity query
Comment #6
Wim LeersDid what I said in #4, and more:
Item
-specific cache tags; just likeMenuLink
s don't get individual cache tags. Use theFeed
cache tags instead, just like theMenu
cache tags.EntityCacheTagsTestBase
base class to support the "default" view mode that theFeed
entity relies upon.Item
entity:Feed
entity:EntityCacheTagsTestBase
was trying to verify the render cache entries, even though they would never exist!Feed::postDelete()
didn't call its parent, hence tag invalidation upon deletion was not happening!In other words: this now also fixes fundamental problems in the
Item
andFeed
entities. I had no choice but to do this, because I couldn't get it to pass the standardized entity test coverage otherwise.Comment #7
Wim LeersTentatively bumping to major, because this fixes so much of the brokenness in aggregator.module (see #6 for details).
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedThe code here looks great.
Are we planning to enable render caching of feeds or items in the future?
Comment #10
Wim LeersSimple fix for the failing test.
Render caching of items doesn't make a lot of sense; render caching of feeds does. I hope that we'll enable it, but it's definitely out of scope for this issue.
Comment #11
moshe weitzman CreditAttribution: moshe weitzman commentedThanks for test fix.
Comment #12
catchI'm confused by this.
The feed items give the Feed cache tag both for getCachetag() and getListCacheTag(), so aren't they handled by Entity:invalidateTagsOnSave() already?
Comment #13
Wim Leers#12: wow, well-spotted, sir! The flaw was in
Item::getListCacheTags()
though, it should've returnedFeed::getListCacheTags()
, notFeed::getCacheTag()
. Sadly we don't have test coverage yet for list cache tags yet, or this would've been detected. Solving that is out of scope for this issue though.Opened an issue for that: #2304987: Don't invalidate cache tags of referenced entities, use entity list cache tags correctly, add test coverage for entity list cache tags.
Comment #14
effulgentsia CreditAttribution: effulgentsia commentedAssigning to catch, since he already started review in #3 and #12.
Comment #15
catchYes this looks fine otherwise. Committed/pushed to 8.x, thanks!
Comment #17
Wim LeersHurray! :)
Comment #18
ParisLiakos CreditAttribution: ParisLiakos commentedthe namespace or folder of
ItemAccessController
is wrong.But seems this class is dead code anyway, since
Item
specifiesFeedAccessController
in the annotation.I guess we should just rm ItemAccessController.php ?
Comment #19
Wim Leers#18: Oops! You're right — strange that none of us noticed that!
Comment #20
ParisLiakos CreditAttribution: ParisLiakos commentedThanks! no problem, thanks for working on this
Comment #21
catchComment #22
catch