Changeset 38925
- Timestamp:
- 10/25/2016 08:47:06 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp.php
r38671 r38925 423 423 $headers['Content-Type'] = feed_content_type( $type ) . '; charset=' . get_option( 'blog_charset' ); 424 424 425 // We're showing a feed, so WP is indeed the only thing that last changed 426 if ( !empty($this->query_vars['withcomments']) 427 || false !== strpos( $this->query_vars['feed'], 'comments-' ) 428 || ( empty($this->query_vars['withoutcomments']) 429 && ( !empty($this->query_vars['p']) 430 || !empty($this->query_vars['name']) 431 || !empty($this->query_vars['page_id']) 432 || !empty($this->query_vars['pagename']) 433 || !empty($this->query_vars['attachment']) 434 || !empty($this->query_vars['attachment_id']) 435 ) 436 ) 437 ) 438 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; 439 else 440 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; 425 // We're showing a feed, so WP is indeed the only thing that last changed. 426 if ( ! empty( $this->query_vars['withcomments'] ) 427 || false !== strpos( $this->query_vars['feed'], 'comments-' ) 428 || ( empty( $this->query_vars['withoutcomments'] ) 429 && ( ! empty( $this->query_vars['p'] ) 430 || ! empty( $this->query_vars['name'] ) 431 || ! empty( $this->query_vars['page_id'] ) 432 || ! empty( $this->query_vars['pagename'] ) 433 || ! empty( $this->query_vars['attachment'] ) 434 || ! empty( $this->query_vars['attachment_id'] ) 435 ) 436 ) 437 ) { 438 $wp_last_modified = mysql2date( 'D, d M Y H:i:s', get_lastcommentmodified( 'GMT' ), false ); 439 } else { 440 $wp_last_modified = mysql2date( 'D, d M Y H:i:s', get_lastpostmodified( 'GMT' ), false ); 441 } 442 443 if ( ! $wp_last_modified ) { 444 $wp_last_modified = date( 'D, d M Y H:i:s' ); 445 } 446 447 $wp_last_modified .= ' GMT'; 448 441 449 $wp_etag = '"' . md5($wp_last_modified) . '"'; 442 450 $headers['Last-Modified'] = $wp_last_modified; -
trunk/src/wp-includes/comment.php
r38852 r38925 294 294 * 295 295 * @since 1.5.0 296 * @since 4.7.0 Replaced caching the modified date in a local static variable 297 * with the Object Cache API. 296 298 * 297 299 * @global wpdb $wpdb WordPress database abstraction object. 298 * @staticvar array $cache_lastcommentmodified 299 * 300 * @param string $timezone Which timezone to use in reference to 'gmt', 'blog', 301 * or 'server' locations. 302 * @return string Last comment modified date. 303 */ 304 function get_lastcommentmodified($timezone = 'server') { 300 * 301 * @param string $timezone Which timezone to use in reference to 'gmt', 'blog', or 'server' locations. 302 * @return string|false Last comment modified date on success, false on failure. 303 */ 304 function get_lastcommentmodified( $timezone = 'server' ) { 305 305 global $wpdb; 306 static $cache_lastcommentmodified = array(); 307 308 if ( isset($cache_lastcommentmodified[$timezone]) ) 309 return $cache_lastcommentmodified[$timezone]; 310 311 $add_seconds_server = date('Z'); 312 313 switch ( strtolower($timezone)) { 306 307 $timezone = strtolower( $timezone ); 308 $key = "lastcommentmodified:$timezone"; 309 310 $comment_modified_date = wp_cache_get( $key, 'timeinfo' ); 311 if ( false !== $comment_modified_date ) { 312 return $comment_modified_date; 313 } 314 315 switch ( $timezone ) { 314 316 case 'gmt': 315 $ lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");317 $comment_modified_date = $wpdb->get_var( "SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" ); 316 318 break; 317 319 case 'blog': 318 $ lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");320 $comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" ); 319 321 break; 320 322 case 'server': 321 $lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server)); 323 $add_seconds_server = date( 'Z' ); 324 325 $comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) ); 322 326 break; 323 327 } 324 328 325 $cache_lastcommentmodified[$timezone] = $lastcommentmodified; 326 327 return $lastcommentmodified; 329 if ( $comment_modified_date ) { 330 wp_cache_set( $key, $comment_modified_date, 'timeinfo' ); 331 332 return $comment_modified_date; 333 } 334 335 return false; 328 336 } 329 337 … … 1574 1582 1575 1583 /** 1584 * Clear the lastcommentmodified cached value when a comment status is changed. 1585 * 1586 * Deletes the lastcommentmodified cache key when a comment enters or leaves 1587 * 'approved' status. 1588 * 1589 * @since 4.7.0 1590 * @access private 1591 * 1592 * @param string $new_status The new comment status. 1593 * @param string $old_status The old comment status. 1594 */ 1595 function _clear_modified_cache_on_transition_comment_status( $new_status, $old_status ) { 1596 if ( 'approved' === $new_status || 'approved' === $old_status ) { 1597 foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) { 1598 wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' ); 1599 } 1600 } 1601 } 1602 1603 /** 1576 1604 * Get current commenter's name, email, and URL. 1577 1605 * … … 1682 1710 if ( $comment_approved == 1 ) { 1683 1711 wp_update_comment_count( $comment_post_ID ); 1712 1713 foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) { 1714 wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' ); 1715 } 1684 1716 } 1685 1717 -
trunk/src/wp-includes/default-filters.php
r38832 r38925 214 214 add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' ); 215 215 add_filter( 'title_save_pre', 'trim' ); 216 217 add_action( 'transition_comment_status', '_clear_modified_cache_on_transition_comment_status', 10, 2 ); 216 218 217 219 add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 ); -
trunk/src/wp-includes/feed-atom-comments.php
r37674 r38925 38 38 <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle> 39 39 40 <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated> 40 <updated><?php 41 $date = get_lastcommentmodified( 'GMT' ); 42 echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date ) : date( 'Y-m-d\TH:i:s\Z' ); 43 ?></updated> 41 44 42 45 <?php if ( is_singular() ) { ?> -
trunk/src/wp-includes/feed-atom.php
r35506 r38925 31 31 <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle> 32 32 33 <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated> 33 <updated><?php 34 $date = get_lastpostmodified( 'GMT' ); 35 echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date ) : date( 'Y-m-d\TH:i:s\Z' ); 36 ?></updated> 34 37 35 38 <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('url') ?>" /> -
trunk/src/wp-includes/feed-rdf.php
r35294 r38925 34 34 <link><?php bloginfo_rss('url') ?></link> 35 35 <description><?php bloginfo_rss('description') ?></description> 36 <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date> 36 <dc:date><?php 37 $date = get_lastpostmodified( 'GMT' ); 38 echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date ) : date( 'Y-m-d\TH:i:s\Z' ); 39 ?></dc:date> 37 40 <sy:updatePeriod><?php 38 41 /** This filter is documented in wp-includes/feed-rss2.php */ -
trunk/src/wp-includes/feed-rss.php
r35294 r38925 15 15 <link><?php bloginfo_rss('url') ?></link> 16 16 <description><?php bloginfo_rss('description') ?></description> 17 <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate> 17 <lastBuildDate><?php 18 $date = get_lastpostmodified( 'GMT' ); 19 echo $date ? mysql2date( 'D, d M Y H:i:s +0000', $date ) : date( 'D, d M Y H:i:s +0000' ); 20 ?></lastBuildDate> 18 21 <docs>http://backend.userland.com/rss092</docs> 19 22 <language><?php bloginfo_rss( 'language' ); ?></language> -
trunk/src/wp-includes/feed-rss2-comments.php
r35294 r38925 44 44 <link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link> 45 45 <description><?php bloginfo_rss("description") ?></description> 46 <lastBuildDate><?php echo mysql2date('r', get_lastcommentmodified('GMT')); ?></lastBuildDate> 46 <lastBuildDate><?php 47 $date = get_lastcommentmodified( 'GMT' ); 48 echo $date ? mysql2date( 'r', $date ) : date( 'r' ); 49 ?></lastBuildDate> 47 50 <sy:updatePeriod><?php 48 51 /** This filter is documented in wp-includes/feed-rss2.php */ -
trunk/src/wp-includes/feed-rss2.php
r37518 r38925 43 43 <link><?php bloginfo_rss('url') ?></link> 44 44 <description><?php bloginfo_rss("description") ?></description> 45 <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate> 45 <lastBuildDate><?php 46 $date = get_lastpostmodified( 'GMT' ); 47 echo $date ? mysql2date( 'D, d M Y H:i:s +0000', $date ) : date( 'D, d M Y H:i:s +0000' ); 48 ?></lastBuildDate> 46 49 <language><?php bloginfo_rss( 'language' ); ?></language> 47 50 <sy:updatePeriod><?php -
trunk/src/wp-includes/post.php
r38852 r38925 5613 5613 5614 5614 $date = wp_cache_get( $key, 'timeinfo' ); 5615 5616 if ( ! $date ) { 5617 if ( 'any' === $post_type ) { 5618 $post_types = get_post_types( array( 'public' => true ) ); 5619 array_walk( $post_types, array( $wpdb, 'escape_by_ref' ) ); 5620 $post_types = "'" . implode( "', '", $post_types ) . "'"; 5621 } else { 5622 $post_types = "'" . sanitize_key( $post_type ) . "'"; 5623 } 5624 5625 switch ( $timezone ) { 5626 case 'gmt': 5627 $date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1"); 5628 break; 5629 case 'blog': 5630 $date = $wpdb->get_var("SELECT post_{$field} FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1"); 5631 break; 5632 case 'server': 5633 $add_seconds_server = date( 'Z' ); 5634 $date = $wpdb->get_var("SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1"); 5635 break; 5636 } 5637 5638 if ( $date ) { 5639 wp_cache_set( $key, $date, 'timeinfo' ); 5640 } 5641 } 5642 5643 return $date; 5615 if ( false !== $date ) { 5616 return $date; 5617 } 5618 5619 if ( 'any' === $post_type ) { 5620 $post_types = get_post_types( array( 'public' => true ) ); 5621 array_walk( $post_types, array( $wpdb, 'escape_by_ref' ) ); 5622 $post_types = "'" . implode( "', '", $post_types ) . "'"; 5623 } else { 5624 $post_types = "'" . sanitize_key( $post_type ) . "'"; 5625 } 5626 5627 switch ( $timezone ) { 5628 case 'gmt': 5629 $date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1"); 5630 break; 5631 case 'blog': 5632 $date = $wpdb->get_var("SELECT post_{$field} FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1"); 5633 break; 5634 case 'server': 5635 $add_seconds_server = date( 'Z' ); 5636 $date = $wpdb->get_var("SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1"); 5637 break; 5638 } 5639 5640 if ( $date ) { 5641 wp_cache_set( $key, $date, 'timeinfo' ); 5642 5643 return $date; 5644 } 5645 5646 return false; 5644 5647 } 5645 5648
Note: See TracChangeset
for help on using the changeset viewer.