Saving or updating a node in Drupal triggers cache_clear_all(NULL, 'cache_page'). However, node deletion does not. Instead, node_delete_multiple() calls
<?php
entity_get_controller('node')->resetCache();
?>
which which clears a static cache but doesn't actually clear the cache in the database. It also fails to call
<?php
_cache_get_object($bin)->clear($cid, $wildcard);
?>
The result is that third-party caching modules such as Redis may fail to properly clear cache upon node deletion and will therefore return stale content.
I noticed this issue while researching a problem with cache clearing in the Redis module, which I have reported separately:
http://drupal.org/node/1841878
Comments
Comment #1
sheldon rampton commentedHere's a patch:
Comment #2
sheldon rampton commentedComment #3
joshk commentedIt might also want to clear the entity cache as well. That will prevent the $node object from appearing to continue to exist in later action in the same boostrap.
Comment #4
sheldon rampton commentedOK, here's an updated patch that also clears the entity cache.
Comment #5
olli commentedNice find. Was this already fixed in D8?
Comment #6
olli commentedLet's see. Moved cache invalidation to submit functions.
Comment #8
olli commented#6: node_deletion_clear_cache-1841900-6.patch queued for re-testing.
Comment #9
ParisLiakos commentedneeds a reroll
Comment #10
olli commentedHere we go.
Comment #11
ParisLiakos commentedthanks!
just two nitpicks i could find.
need visibility
should use $this->container like:
$this->container->get('config.factory')->get('system.performance');
Comment #12
olli commentedThank you!
Comment #13
ParisLiakos commentedthanks!
lets get it in!
Comment #14
alexpottNice find.
Committed f805ecf and pushed to 8.x. Thanks!
Comment #15
herom commentedbackport patch to 7.x
Comment #17
ParisLiakos commentedhi herom, thanks for rolling this!
this call should happen in the form submit handlers not here, because, well, if you call that function many times programmatically, that would make things significantly slower;)
so this should go in node_delete_confirm_submit() and in node_multiple_delete_confirm_submit()
Comment #18
herom commentednew patch.
Comment #19
ParisLiakos commentedthanks looks good!
Comment #20
David_Rothstein commentedCommitted to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/df93dd2