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.
Editing a block via context doesn't clear cache for that block, I need to manually clear cache every time after I edit a block config. I think the fix might be to call Cache::invalidateTags()
on the block tags every time that block gets saved.
Comment | File | Size | Author |
---|---|---|---|
#7 | 2979259-6.patch | 3.07 KB | nace_fr |
#5 | context.2979259.context_entity_cache_tags.patch | 3.18 KB | George Bills |
Comments
Comment #2
George Bills CreditAttribution: George Bills commentedIt seems like:
So I think the fix is actually just to add the context entity cache tags to the block render array we return from Blocks::execute(). We shouldn't need to explicitly call Cache::invalidateTags().
Comment #3
George Bills CreditAttribution: George Bills commentedAttached is a "proof of concept" for a fix, I haven't figured out how to get access to the current context from inside the Blocks ContextReaction plugin yet; possibly need to pass it down from ContextManager? Also need to DI the entity type manager.
With this patch changing block configuration for a context block on my homepage will refresh cache for that block, without this patch changing block configuration for a context block on my homepage won't take show any effect until I manually flush cache.
Comment #4
George Bills CreditAttribution: George Bills commentedActually attach the patch.
Comment #5
George Bills CreditAttribution: George Bills commentedActual patch (was easier than I thought to get the context) - this works on my local.
Comment #6
nace_fr CreditAttribution: nace_fr at Agiledrop - Your Trusted Drupal Teammates commentedI fixed the patch apply failing.
Comment #7
nace_fr CreditAttribution: nace_fr at Agiledrop - Your Trusted Drupal Teammates commentedComment #8
strozx CreditAttribution: strozx commentedTested the patch and it works. Thank you Nace
Comment #9
strozx CreditAttribution: strozx commentedComment #10
Feng-Shui CreditAttribution: Feng-Shui commentedThis is a re-roll against 8.x-4.0-beta2, not against head - the two patches above didn't apply on the current release.
Comment #12
boshtian CreditAttribution: boshtian at Agiledrop - Your Trusted Drupal Teammates commented