Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When EntityManager was written, CacheDecorator did not support cache tags, so it implements its own caching.
Now that CacheDecorator does support cache tags, it should likely switch back.
Comment | File | Size | Author |
---|---|---|---|
#16 | interdiff.txt | 1.02 KB | tim.plunkett |
#16 | entity-1892462-16.patch | 6.75 KB | tim.plunkett |
#10 | entity-1892462-10.patch | 6.13 KB | tim.plunkett |
#10 | interdiff.txt | 741 bytes | tim.plunkett |
#9 | entity-1892462-9.patch | 5.93 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettSince the CacheDecorator also provides static caching, we can simplify entity_get_info() to the point where it shouldn't be called anymore.
Comment #2
yched CreditAttribution: yched commentedBig, big +1.
However :
EntityManager::clearCachedDefinitions() will only clear the data for the current language, won't it ?
(aka #1722882-41: Plugin CacheDecorator caches globally, ignores request context, and does not specify tags for cache items)
2 days to next Drupal core point release.
Comment #3
tim.plunkettCacheDecorator::clearCachedDefinitions() will work for all languages if you use cache tags, which we do, and #1893818: Plugin discovery caches of blocks are not cleared for all languages does not. We're good here :)
Comment #4
tim.plunkettComment #5
tstoecklerLooks good.
I was a bit confused that the cache tags are declared as
array('entity_info' => TRUE)
, while the issue in #3 doesarray('block')
. I *think* both work, but easier way I think the method here seems to be more standard as cache tags were primarily introduced for thearray('node' => array(1, 2, 3))
use-case.Comment #6
yched CreditAttribution: yched commented@tim : Ah, right, skipped that. Too long since I've been able to crack my D8 open :-/
(+ sorry about status change, was not intentional)
Comment #8
tim.plunkettDebugging. The main failing test is the one for this caching specifically, so that's good to see we have coverage :)
Comment #9
tim.plunkettEntityTranslationSettingsTest was calling drupal_static_reset() when all it needed was entity_info_cache_clear(), and I added a call to clear the static cache of EntityManager in drupal_flush_all_caches() under the section intended for just that!
Comment #10
tim.plunkettActually, we should do this, so that it's clear what is actually happening, and it's clearer what to convert to.
Comment #11
EclipseGc CreditAttribution: EclipseGc commentedAssuming it passes tests, this looks pretty sane to me.
RTBC
Comment #12
sunBumping to major, since the
drupal_static()
inentity_get_info()
actually causes a mismatch between actual discovery info and statically cached info at runtime, which took me some hours of debugging to figure out in #1901380: [Block]PluginManager repetitively triggers full-stack Annotation parsing on a plugin instance ID missThe changes here seem to be identical with regard to the EntityManager, so let's make sure to get this in ASAP.
Only a few remarks:
(If anything I'm saying is not the case, then we need crystal clear comments that explain why the respective code is still needed.)
This should not be necessary. All caches are flushed before that call already, and the entire kernel/container is rebuilt a few lines below.
Likewise, this should simply vanish.
Tests simply call into
$this->rebuildContainer()
. This one might still need the static reset for the bundles/view-modes though.Comment #14
tim.plunkettAll of the calls to clearCachedDefinitions() are for the static caching provided by CacheDecorator, not the cache backend caching. Trust me, they're needed, see the failures in #1.
If we want to have a separate call to clear the static caches of CacheDecorator, that's fine, but in HEAD we only have clearCachedDefinitions().
Comment #15
sunLet's document that then.
Comment #16
tim.plunkettOkay, documented. I think the above confusion was because sun thought #1872522: Compiled data in PHP storage is cleared too late in drupal_flush_all_caches() had gone in already.
Comment #17
sunThanks, works for me! Agreed with RTBC. Time to get rid of that static! :)
Hopefully it comes back green.
Comment #19
tim.plunkett#16: entity-1892462-16.patch queued for re-testing.
Comment #20
tim.plunkettRandom failure in FilledMinimalUpgradePathTest.
Comment #21
catchThat's very nice. Committed/pushed to 8.x.
Comment #23
podarokthis one filled with change record due to @depretaced function
needs review
Comment #24
ParisLiakos CreditAttribution: ParisLiakos commentedstill a task, right?
Comment #25
tim.plunkettThis is fine.