Commit 4e0071fb authored by Gábor Hojtsy's avatar Gábor Hojtsy

#111127 rollback by chx, slightly extended: roll back node_load cache, it...

#111127 rollback by chx, slightly extended: roll back node_load cache, it needs more thought and discussion, so postponed until at least Drupal 7
parent bfb72d0e
......@@ -564,8 +564,6 @@ function book_remove_form_submit($form, &$form_state) {
// Only allowed when this is not a book (top-level page).
menu_link_delete($node->book['mlid']);
db_query('DELETE FROM {book} WHERE nid = %d', $node->nid);
// Clear the node load cache.
cache_clear_all('*', 'cache_node', TRUE);
drupal_set_message(t('The post has been removed from the book.'));
}
$form_state['redirect'] = 'node/'. $node->nid;
......@@ -611,8 +609,6 @@ function _book_update_outline(&$node) {
// Update the bid for this page and all children.
book_update_bid($node->book);
}
// Clear the node load cache.
cache_clear_all('*', 'cache_node', TRUE);
}
return TRUE;
}
......
......@@ -2035,7 +2035,6 @@ function _comment_update_node_statistics($nid) {
$node = db_fetch_object(db_query("SELECT uid, created FROM {node} WHERE nid = %d", $nid));
db_query("UPDATE {node_comment_statistics} SET comment_count = 0, last_comment_timestamp = %d, last_comment_name = '', last_comment_uid = %d WHERE nid = %d", $node->created, $node->uid, $nid);
}
cache_clear_all($nid, 'cache_node');
}
/**
......
......@@ -444,7 +444,6 @@ function node_type_delete($type) {
*/
function node_type_update_nodes($old_type, $type) {
db_query("UPDATE {node} SET type = '%s' WHERE type = '%s'", $type, $old_type);
cache_clear_all('*', 'cache_node', TRUE);
return db_affected_rows();
}
......@@ -601,17 +600,6 @@ function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
/**
* Load a node object from the database.
*
* This function provides two levels of caching. The internal cache stores
* all nodes loaded in this request. Use the $reset argument to invalidate
* it. The cache API based cache stores all nodes throughout requests,
* until invalidated with cache_clear_all().
*
* If the load operation was cached previously, we load the data from
* that cache, and no nodeapi load operations are called. That means,
* that we expect all load operations to return the same data and do
* not use any conditions on the user, language or anything else,
* which would limit what is stored in the node_load cache.
*
* @param $param
* Either the nid of the node or an array of conditions to match against in the database query
* @param $revision
......@@ -633,13 +621,7 @@ function node_load($param = array(), $revision = NULL, $reset = NULL) {
$arguments = array();
if (is_numeric($param)) {
if ($cachable) {
if (!isset($nodes[$param])) {
if ($cache = cache_get($param, 'cache_node')) {
$nodes[$param] = $cache->data;
}
}
// Either the node was statically cached or we loaded from the
// cache_node table.
// Is the node statically cached?
if (isset($nodes[$param])) {
return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
}
......@@ -685,11 +667,6 @@ function node_load($param = array(), $revision = NULL, $reset = NULL) {
}
if ($cachable) {
$nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node;
// We can only cache when a nid is given, otherwise the conditions are
// too dynamic to be cacheable.
if (is_numeric($param)) {
cache_set($param, $nodes[$node->nid], 'cache_node');
}
}
}
......@@ -886,8 +863,6 @@ function node_save(&$node) {
// Clear the page and block caches.
cache_clear_all();
// Clear the node load cache for this node.
cache_clear_all($node->nid, 'cache_node');
}
/**
......@@ -1218,7 +1193,6 @@ function node_user($op, &$edit, &$user) {
if ($op == 'delete') {
db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid);
db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid);
cache_clear_all('*', 'cache_node', TRUE);
}
}
......
......@@ -105,7 +105,5 @@ function node_schema() {
'primary key' => array('type'),
);
$schema['cache_node'] = drupal_get_schema_unprocessed('system', 'cache');
return $schema;
}
......@@ -821,7 +821,6 @@ function system_modules_submit($form, &$form_state) {
node_types_rebuild();
menu_rebuild();
cache_clear_all('schema', 'cache');
cache_clear_all('*', 'cache_node', TRUE);
drupal_set_message(t('The configuration options have been saved.'));
}
......
......@@ -3698,24 +3698,8 @@ function system_update_6027() {
* Add the node load cache table.
*/
function system_update_6028() {
$ret = array();
// Create the cache_node table.
$schema['cache_node'] = array(
'fields' => array(
'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'headers' => array('type' => 'text', 'not null' => FALSE),
'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
),
'indexes' => array('expire' => array('expire')),
'primary key' => array('cid'),
);
db_create_table($ret, 'cache_node', $schema['cache_node']);
return $ret;
// Removed node_load cache to discuss it more for Drupal 7.
return array();
}
/**
......
......@@ -256,7 +256,6 @@ function translation_nodeapi(&$node, $op, $teaser, $page) {
db_query("UPDATE {node} SET tnid = %d, translate = %d WHERE nid = %d", $tnid, 0, $node->translation_source->nid);
}
db_query("UPDATE {node} SET tnid = %d, translate = %d WHERE nid = %d", $tnid, 0, $node->nid);
translation_clear_node_cache($tnid);
}
break;
......@@ -268,7 +267,6 @@ function translation_nodeapi(&$node, $op, $teaser, $page) {
// This is the source node, asking to mark all translations outdated.
db_query("UPDATE {node} SET translate = 1 WHERE tnid = %d AND nid != %d", $node->tnid, $node->nid);
}
translation_clear_node_cache($node->tnid);
}
break;
......@@ -297,25 +295,10 @@ function translation_remove_from_set($node) {
$new_tnid = db_result(db_query('SELECT nid FROM {node} WHERE tnid = %d ORDER BY translate ASC, nid ASC', $node->tnid));
db_query('UPDATE {node} SET tnid = %d WHERE tnid = %d', $new_tnid, $node->tnid);
}
translation_clear_node_cache($node->tnid);
}
}
}
/**
* Clear node_load cache for all nodes in the translation set, so we have
* the proper translation set information in every node.
*
* @param $tnid
* The translation source nid of the translation set, the identifier
* of the node used to derive all translations in the set.
*/
function translation_clear_node_cache($tnid) {
foreach (translation_node_get_translations($tnid) as $node) {
cache_clear_all($node->nid, 'cache_node');
}
}
/**
* Get all nodes in a translation set, represented by $tnid.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment