- Patch #757484 by catch: optimize node_save().

merge-requests/26/head
Dries Buytaert 2010-03-31 13:55:25 +00:00
parent d0f81a1fba
commit 3e10914bc5
2 changed files with 12 additions and 7 deletions

View File

@ -1072,15 +1072,14 @@ function node_save($node) {
module_invoke_all('node_' . $op, $node);
entity_invoke($op, 'node', $node);
// Update the node access table for this node.
node_access_acquire_grants($node);
// Update the node access table for this node. There's no need to delete
// existing records if the node is new.
$delete = $op == 'insert';
node_access_acquire_grants($node, $delete);
// Clear internal properties.
unset($node->is_new);
// Clear the page and block caches.
cache_clear_all();
// Ignore slave server temporarily to give time for the
// saved node to be propagated to the slave.
db_ignore_slave();
@ -3062,8 +3061,12 @@ function node_query_node_access_alter(QueryAlterableInterface $query) {
*
* @param $node
* The $node to acquire grants for.
*
* @param $delete
* Whether to delete existing node access records before inserting new ones.
* Defaults to TRUE.
*/
function node_access_acquire_grants($node) {
function node_access_acquire_grants($node, $delete = TRUE) {
$grants = module_invoke_all('node_access_records', $node);
// Let modules alter the grants.
drupal_alter('node_access_records', $grants, $node);
@ -3081,7 +3084,7 @@ function node_access_acquire_grants($node) {
$grants = array_shift($grant_by_priority);
}
node_access_write_grants($node, $grants);
node_access_write_grants($node, $grants, NULL, $delete);
}
/**

View File

@ -401,6 +401,8 @@ function node_form_submit($form, &$form_state) {
// rebuilt and node form redisplayed the same way as in preview.
drupal_set_message(t('The post could not be saved.'), 'error');
}
// Clear the page and block caches.
cache_clear_all();
}
/**