Issue #1841900 by olli, herom, Sheldon Rampton: Node deletion should clear page cache.

merge-requests/26/head
David Rothstein 2013-12-29 14:51:49 -05:00
parent d453b28cba
commit df93dd273a
4 changed files with 79 additions and 0 deletions

View File

@ -1,6 +1,8 @@
Drupal 7.25, xxxx-xx-xx (development version)
-----------------------
- Fixed a bug in which caches were not properly cleared when a node was deleted
via the administrative interface.
- Changed the Bartik theme to render content contained in <pre>, <code> and
similar tags in a larger font size, so it is easier to read.
- Fixed a bug in the Search module that caused exceptions to be thrown during

View File

@ -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.'));

View File

@ -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)));
}

View File

@ -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);
}
}