WordPress.org

Make WordPress Core

Ticket #137: 0000137-comments_feed_modtime.patch

File 0000137-comments_feed_modtime.patch, 2.5 KB (added by kelson, 10 years ago)
  • wp-blog-header.php

    diff -r -U 2 wordpress/wp-blog-header.php wordpress-modified/wp-blog-header.php
    old new  
    115115} else { 
    116116        // We're showing a feed, so WP is indeed the only thing that last changed 
    117         $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; 
     117        if ($withcomments) { 
     118                $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; 
     119        } else { 
     120                $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; 
     121        } 
    118122        $wp_etag = '"' . md5($wp_last_modified) . '"'; 
    119123        @header('Last-Modified: '.$wp_last_modified); 
  • wp-commentsrss2.php

    diff -r -U 2 wordpress/wp-commentsrss2.php wordpress-modified/wp-commentsrss2.php
    old new  
    11<?php  
    22if (! $feed) { 
     3    $withcomments = 1; 
    34    require('wp-blog-header.php'); 
    45} 
  • wp-includes/functions.php

    diff -r -U 2 wordpress/wp-includes/functions.php wordpress-modified/wp-includes/functions.php
    old new  
    142142} 
    143143 
     144function get_lastcommentmodified($timezone = 'server') { 
     145        global $tablecomments, $cache_lastcommentmodified, $pagenow, $wpdb; 
     146        $add_seconds_blog = get_settings('gmt_offset') * 3600; 
     147        $add_seconds_server = date('Z'); 
     148        $now = current_time('mysql', 1); 
     149        if ( !isset($cache_lastcommentmodified[$timezone]) ) { 
     150                switch(strtolower($timezone)) { 
     151                        case 'gmt': 
     152                                $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $tablecomments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); 
     153                                break; 
     154                        case 'blog': 
     155                                $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $tablecomments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); 
     156                                break; 
     157                        case 'server': 
     158                                $lastcommentmodified = $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $tablecomments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); 
     159                                break; 
     160                } 
     161                $cache_lastcommentmodified[$timezone] = $lastcommentmodified; 
     162        } else { 
     163                $lastcommentmodified = $cache_lastcommentmodified[$timezone]; 
     164        } 
     165        return $lastcommentmodified; 
     166} 
     167 
    144168function user_pass_ok($user_login,$user_pass) { 
    145169        global $cache_userdata;