=== modified file 'includes/bootstrap.inc' --- includes/bootstrap.inc 2007-10-05 14:50:25 +0000 +++ includes/bootstrap.inc 2007-10-08 06:38:53 +0000 @@ -567,7 +567,7 @@ function drupal_load($type, $name) { */ function drupal_page_header() { header("Expires: Sun, 19 Nov 1978 05:00:00 GMT"); - header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT"); + header("Last-Modified: ". gmdate("D, d M Y H:i:s", drupal_get_page_last_modified()) ." GMT"); header("Cache-Control: store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", FALSE); } @@ -583,7 +583,7 @@ function drupal_page_header() { */ function drupal_page_cache_header($cache) { // Set default values: - $last_modified = gmdate('D, d M Y H:i:s', $cache->created) .' GMT'; + $last_modified = gmdate('D, d M Y H:i:s', $cache->last_modified) .' GMT'; $etag = '"'. md5($last_modified) .'"'; // See if the client has provided the required HTTP headers: @@ -628,6 +628,42 @@ function drupal_page_cache_header($cache } /** + * Set a page's age + * + * Call this function if you want to set the timestamp of a pages age. + * + * @param $date a timestamp + * + * @return the highest timestamp passed into this function so far. + */ +function drupal_set_page_last_modified($date = 0) { + static $cache_date = 0; + + if ($date > $cache_date) { + $cache_date = $date; + } + + return $cache_date; +} + +/** + * Get cache date + * + * @return the highest timestamp passed into drupal_set_page_last_modified so far or the current time. + */ +function drupal_get_page_last_modified() { + $date = drupal_set_page_last_modified(); + $time = time(); + + if ($date < $time && $date > 0) { + return $date; + } + else { + return $time; + } +} + +/** * Define the critical hooks that force modules to always be loaded. */ function bootstrap_hooks() { === modified file 'includes/cache.inc' --- includes/cache.inc 2007-08-26 09:33:49 +0000 +++ includes/cache.inc 2007-10-08 06:38:53 +0000 @@ -22,7 +22,7 @@ function cache_get($cid, $table = 'cache variable_set('cache_flush', 0); } - $cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {". $table ."} WHERE cid = '%s'", $cid)); + $cache = db_fetch_object(db_query("SELECT data, created, last_modified, headers, expire, serialized FROM {". $table ."} WHERE cid = '%s'", $cid)); if (isset($cache->data)) { // If the data is permanent or we're not enforcing a minimum cache lifetime // always return the cached data. @@ -104,10 +104,13 @@ function cache_set($cid, $data, $table = $data = serialize($data); $serialized = 1; } + $created = time(); - db_query("UPDATE {". $table ."} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, $created, $expire, $headers, $serialized, $cid); + $last_modified = drupal_get_page_last_modified(); + + db_query("UPDATE {". $table ."} SET data = %b, created = %d, last_modified = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, $created, $last_modified, $expire, $headers, $serialized, $cid); if (!db_affected_rows()) { - @db_query("INSERT INTO {". $table ."} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, $data, $created, $expire, $headers, $serialized); + @db_query("INSERT INTO {". $table ."} (cid, data, created, last_modified, expire, headers, serialized) VALUES ('%s', %b, %d, %d, %d, '%s', %d)", $cid, $data, $created, $last_modified, $expire, $headers, $serialized); } } === modified file 'modules/block/block.module' --- modules/block/block.module 2007-10-06 16:08:50 +0000 +++ modules/block/block.module 2007-10-08 06:38:53 +0000 @@ -438,6 +438,7 @@ function block_list($region) { // by fetching from cache only if the request method is 'GET'. if (!count(module_implements('node_grants')) && $_SERVER['REQUEST_METHOD'] == 'GET' && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) { $array = $cache->data; + drupal_set_page_last_modified($cache->last_modified); } else { $array = module_invoke($block->module, 'block', 'view', $block->delta); === modified file 'modules/comment/comment.module' --- modules/comment/comment.module 2007-10-07 19:25:57 +0000 +++ modules/comment/comment.module 2007-10-08 06:38:53 +0000 @@ -573,6 +573,9 @@ function comment_form_alter(&$form, $for */ function comment_nodeapi(&$node, $op, $arg = 0) { switch ($op) { + case 'view': + drupal_set_page_last_modified($node->last_comment_timestamp); + break; case 'load': return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid)); break; @@ -990,6 +993,7 @@ function comment_render($node, $cid = 0) $mode = _comment_get_display_setting('mode', $node); $order = _comment_get_display_setting('sort', $node); $comments_per_page = _comment_get_display_setting('comments_per_page', $node); + $latest = 0; if ($cid && is_numeric($cid)) { // Single comment view. @@ -1007,6 +1011,7 @@ function comment_render($node, $cid = 0) $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $links = module_invoke_all('link', 'comment', $comment, 1); drupal_alter('link', $links, $node); + $latest = ($comment->timestamp > $latest) ? $comment->timestamp : $latest; $output .= theme('comment_view', $comment, $node, $links); } @@ -1077,6 +1082,8 @@ function comment_render($node, $cid = 0) } } + $latest = ($comment->timestamp > $latest) ? $comment->timestamp : $latest; + if ($mode == COMMENT_MODE_FLAT_COLLAPSED) { $comments .= theme('comment_flat_collapsed', $comment, $node); } @@ -1116,6 +1123,8 @@ function comment_render($node, $cid = 0) } $output = theme('comment_wrapper', $output, $node); + + drupal_set_page_last_modified($latest); } return $output; @@ -1300,6 +1309,8 @@ function theme_comment_admin_overview($f $row[] = drupal_render($form['operations'][$key]); $rows[] = $row; } + + drupal_set_page_last_modified($latest); } else { $rows[] = array(array('data' => t('No comments available.'), 'colspan' => '6')); === modified file 'modules/node/node.module' --- modules/node/node.module 2007-10-03 17:35:22 +0000 +++ modules/node/node.module 2007-10-08 06:38:53 +0000 @@ -905,6 +905,8 @@ function node_view($node, $teaser = FALS // Allow modules to modify the fully-built node. node_invoke_nodeapi($node, 'alter', $teaser, $page); + drupal_set_page_last_modified($node->changed); + return theme('node', $node, $teaser, $page); } @@ -953,6 +955,8 @@ function node_build_content($node, $teas $node->build_mode = NODE_BUILD_NORMAL; } + drupal_set_page_last_modified($node->changed); + // Remove the delimiter (if any) that separates the teaser from the body. $node->body = isset($node->body) ? str_replace('', '', $node->body) : ''; === modified file 'modules/system/system.install' --- modules/system/system.install 2007-10-05 14:43:23 +0000 +++ modules/system/system.install 2007-10-08 06:39:45 +0000 @@ -344,12 +344,13 @@ function system_schema() { $schema['cache'] = 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) + '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), + 'last_modified' => 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'), @@ -3992,6 +3993,20 @@ function system_update_6033() { /** + * Add last_modified timestamp to cache tables. + */ +function system_update_6034() { + $ret = array(); + db_add_field($ret, 'cache_block', 'last_modified', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); + db_add_field($ret, 'cache_filter', 'last_modified', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); + db_add_field($ret, 'cache_form', 'last_modified', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); + db_add_field($ret, 'cache_menu', 'last_modified', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); + db_add_field($ret, 'cache_page', 'last_modified', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); + db_add_field($ret, 'cache_update', 'last_modified', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); + return $ret; +} + +/** * @} End of "defgroup updates-5.x-to-6.x" * The next series of updates should start at 7000. */ === modified file 'modules/tracker/tracker.pages.inc' --- modules/tracker/tracker.pages.inc 2007-10-07 19:25:57 +0000 +++ modules/tracker/tracker.pages.inc 2007-10-08 06:38:53 +0000 @@ -48,6 +48,7 @@ function tracker_page($uid = 0) { $result = pager_query($sql, 25, 0, $sql_count); } + $latest = 0; $rows = array(); while ($node = db_fetch_object($result)) { // Determine the number of comments: @@ -68,12 +69,16 @@ function tracker_page($uid = 0) { array('class' => 'replies', 'data' => $comments), t('!time ago', array('!time' => format_interval(time() - $node->last_updated))) ); + + $latest = ($node->last_updated > $latest) ? $node->last_updated : $latest; } if (!$rows) { $rows[] = array(array('data' => t('No posts available.'), 'colspan' => '5')); } + drupal_set_page_last_modified($latest); + $header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated')); $output = '