diff --git a/modules/node/node.admin.inc b/modules/node/node.admin.inc index be09b37..0d0bbc0 100644 --- a/modules/node/node.admin.inc +++ b/modules/node/node.admin.inc @@ -695,6 +695,7 @@ function node_multiple_delete_confirm($form, &$form_state, $nodes) { function node_multiple_delete_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { node_delete_multiple(array_keys($form_state['values']['nodes'])); + cache_clear_all(); $count = count($form_state['values']['nodes']); watchdog('content', 'Deleted @count posts.', array('@count' => $count)); drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.')); diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index 75ed0dd..6267463 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -542,6 +542,7 @@ function node_delete_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { $node = node_load($form_state['values']['nid']); node_delete($form_state['values']['nid']); + cache_clear_all(); watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title)); drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title))); } diff --git a/modules/node/node.test b/modules/node/node.test index b1d78fa..3cafefa 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -2755,3 +2755,78 @@ class NodeEntityViewModeAlterTest extends NodeWebTestCase { $this->assertEqual($build['#view_mode'], 'teaser', 'The view mode has correctly been set to teaser.'); } } + +/** + * Tests the cache invalidation of node operations. + */ +class NodePageCacheTest extends NodeWebTestCase { + + /** + * An admin user with administrative permissions for nodes. + */ + protected $admin_user; + + public static function getInfo() { + return array( + 'name' => 'Node page cache test', + 'description' => 'Test cache invalidation of node operations.', + 'group' => 'Node', + ); + } + + function setUp() { + parent::setUp(); + + variable_set('cache', 1); + variable_set('page_cache_maximum_age', 300); + + $this->admin_user = $this->drupalCreateUser(array( + 'bypass node access', + 'access content overview', + 'administer nodes', + )); + } + + /** + * Tests deleting nodes clears page cache. + */ + public function testNodeDelete() { + $node_path = 'node/' . $this->drupalCreateNode()->nid; + + // Populate page cache. + $this->drupalGet($node_path); + + // Login and delete the node. + $this->drupalLogin($this->admin_user); + $this->drupalPost($node_path . '/delete', array(), t('Delete')); + + // Logout and check the node is not available. + $this->drupalLogout(); + $this->drupalGet($node_path); + $this->assertResponse(404); + + // Create two new nodes. + $nodes[0] = $this->drupalCreateNode(); + $nodes[1] = $this->drupalCreateNode(); + $node_path = 'node/' . $nodes[0]->nid; + + // Populate page cache. + $this->drupalGet($node_path); + + // Login and delete the nodes. + $this->drupalLogin($this->admin_user); + $this->drupalGet('admin/content'); + $edit = array( + 'operation' => 'delete', + 'nodes[' . $nodes[0]->nid . ']' => TRUE, + 'nodes[' . $nodes[1]->nid . ']' => TRUE, + ); + $this->drupalPost(NULL, $edit, t('Update')); + $this->drupalPost(NULL, array(), t('Delete')); + + // Logout and check the node is not available. + $this->drupalLogout(); + $this->drupalGet($node_path); + $this->assertResponse(404); + } +}