#111127 rollback by chx, slightly extended: roll back node_load cache, it needs more thought and discussion, so postponed until at least Drupal 7

6.x
Gábor Hojtsy 2007-08-30 15:31:46 +00:00
parent bfb72d0ec9
commit 4e0071fb8a
7 changed files with 18 additions and 85 deletions

View File

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

View File

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

View File

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

View File

@ -105,7 +105,5 @@ function node_schema() {
'primary key' => array('type'),
);
$schema['cache_node'] = drupal_get_schema_unprocessed('system', 'cache');
return $schema;
}

View File

@ -123,7 +123,7 @@ function system_settings_overview() {
/**
* Form builder; This function allows selection of the theme to show in administration sections.
*
*
* @ingroup forms
* @see system_settings_form().
*/
@ -156,7 +156,7 @@ function system_admin_theme_settings() {
/**
* Menu callback; displays a listing of all themes.
*
*
* @ingroup forms
* @see system_themes_form_submt().
*/
@ -280,7 +280,7 @@ function system_themes_form_submit($form, &$form_state) {
/**
* Form builder; display theme configuration for entire site and individual themes.
*
*
* @ingroup forms
* @see system_theme_settings_submit().
*/
@ -693,7 +693,7 @@ function system_modules_disable($form, $edit) {
* elements: the list of dependencies and the list of status
* form field values from the previous screen.
* @ingroup forms
* @see
* @see
*/
function system_modules_confirm_form($modules, $storage) {
$form = array();
@ -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.'));
}
@ -1010,7 +1009,7 @@ function system_modules_uninstall_submit($form, &$form_state) {
/**
* Form builder; The general site information form.
*
*
* @ingroup forms
* @see system_settings_form().
*/
@ -1068,7 +1067,7 @@ function system_site_information_settings() {
/**
* Form builder; Configure error reporting settings.
*
*
* @ingroup forms
* @see system_settings_form().
*/
@ -1115,7 +1114,7 @@ function system_logging_overview() {
/**
* Form builder; Configure site performance settings.
*
*
* @ingroup forms
* @see system_settings_form().
*/
@ -1218,7 +1217,7 @@ function system_performance_settings() {
/**
* Form builder; Configure the site file handling.
*
*
* @ingroup forms
* @see system_settings_form().
*/
@ -1255,7 +1254,7 @@ function system_file_system_settings() {
/**
* Form builder; Configure site image toolkit usage.
*
*
* @ingroup forms
* @see system_settings_form().
*/
@ -1280,7 +1279,7 @@ function system_image_toolkit_settings() {
/**
* Form builder; Configure how the site handles RSS feeds.
*
*
* @ingroup forms
* @see system_settings_form().
*/
@ -1306,7 +1305,7 @@ function system_rss_feeds_settings() {
/**
* Form builder; Configure the site date and time settings.
*
*
* @ingroup forms
* @see system_settings_form().
* @see system_date_time_settings().
@ -1476,7 +1475,7 @@ function system_date_time_lookup() {
/**
* Form builder; Configure the site's maintenance status.
*
*
* @ingroup forms
* @see system_settings_form().
*/
@ -1502,7 +1501,7 @@ function system_site_maintenance_settings() {
/**
* Form builder; Configure Clean URL settings.
*
*
* @ingroup forms
* @see system_settings_form().
*/
@ -1802,7 +1801,7 @@ function theme_system_admin_by_module($menu_items) {
/**
* Theme status report
*
*
* @ingroup themeable
*/
function theme_status_report(&$requirements) {
@ -1837,7 +1836,7 @@ function theme_status_report(&$requirements) {
/**
* Theme call back for the modules form.
*
*
* @ingroup themeable
*/
function theme_system_modules($form) {

View File

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

View File

@ -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.
*