Ticket #11334: 11334-3.5.1.patch
| File 11334-3.5.1.patch, 4.4 KB (added by , 13 years ago) |
|---|
-
wp-includes/comment.php
old new 851 851 if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) 852 852 return get_page_of_comment( $comment->comment_parent, $args ); 853 853 854 $allowedtypes = array( 855 'comment' => '', 856 'pingback' => 'pingback', 857 'trackback' => 'trackback', 858 ); 854 switch ( $args['type'] ) { 855 case 'comment': 856 $comtype = 'comment'; 857 $comtypewhere = " AND comment_type = ''"; 858 break; 859 case 'pingback': 860 $comtype = 'pingback'; 861 $comtypewhere = " AND comment_type = 'pingback'"; 862 break; 863 case 'trackback': 864 $comtype = 'trackback'; 865 $comtypewhere = " AND comment_type = 'trackback'"; 866 break; 867 case 'pings': 868 $comtype = 'pings'; 869 $comtypewhere = " AND ( comment_type = 'pingback' OR comment_type = 'trackback' )"; 870 break; 871 default; 872 $comtype = 'all'; 873 $comtypewhere = ''; 874 } 859 875 860 $comtypewhere = ( 'all' != $args['type'] && isset($allowedtypes[$args['type']]) ) ? " AND comment_type = '" . $allowedtypes[$args['type']] . "'" : '';861 876 862 // Count comments older than this one 877 $cachekey = 'post-' . $comment->comment_post_ID; 878 // Check the cache and set it up if it's not set (so we can use replace later on) 879 if ( false === $oldercoms_cache = wp_cache_get( $cachekey, 'comment_pages' ) ) { 880 $oldercoms_cache = array(); 881 wp_cache_add( $cachekey, $oldercoms_cache, 'comment_pages' ); 882 } 883 $oldercoms_cache = (array) $oldercoms_cache; 884 885 // Get comments older than this comment 886 $oldercoms = ( isset( $oldercoms_cache[$comtype] ) && isset( $oldercoms_cache[$comtype][$comment->comment_ID] ) ) ? $oldercoms_cache[$comtype][$comment->comment_ID] : false; 887 if ( false === $oldercoms ) { 863 888 $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) ); 889 $oldercoms_cache[$comtype][$comment->comment_ID] = $oldercoms; 890 wp_cache_replace( $cachekey, $oldercoms_cache, 'comment_pages' ); 891 } 864 892 865 893 // No older comments? Then it's page #1. 866 894 if ( 0 == $oldercoms ) … … 871 899 } 872 900 873 901 /** 902 * Clears the cache used by get_page_of_comment(). Is designed to be attached to the 903 * 'clear_page_of_comment_cache' action inside of wp_transition_comment_status(); 904 * 905 * @since 2.9.0 906 * @uses wp_cache_delete() Does the cache deleting. 907 * 908 * @param string $new_status Unused 909 * @param string $old_status Unused 910 * @param object $comment Comment object that had it's status changed 911 * @return bool True on successful removal, false on failure 912 */ 913 function clear_page_of_comment_cache( $new_status, $old_status, $comment ) { 914 return wp_cache_delete( 'post-' . $comment->comment_post_ID, 'comment_pages' ); 915 } 916 917 /** 874 918 * Does comment contain blacklisted characters or words. 875 919 * 876 920 * @since 1.5.0 -
wp-includes/default-filters.php
old new 256 256 add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); 257 257 add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' ); 258 258 add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts' ); 259 add_action( 'transition_comment_status', 'clear_page_of_comment_cache' ); 259 260 add_action( 'admin_init', 'send_frame_options_header', 10, 0 ); 260 261 add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment' ); 261 262 add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment' );