Ticket #50159: #50159-v2.patch
File #50159-v2.patch, 4.7 KB (added by , 5 years ago) |
---|
-
wp-includes/class-wp-feed-cache-transient.php
12 12 * 13 13 * @since 2.8.0 14 14 */ 15 class WP_Feed_Cache_Transient {15 class WP_Feed_Cache_Transient implements SimplePie_Cache_Base { 16 16 17 17 /** 18 18 * Holds the transient name. … … 48 48 * 49 49 * @param string $location URL location (scheme is used to determine handler). 50 50 * @param string $filename Unique identifier for cache object. 51 * @param string $extension 'sp i' or 'spc'.51 * @param string $extension 'spc' (Feed cache type) or 'spi' (Image cache type) 52 52 */ 53 53 public function __construct( $location, $filename, $extension ) { 54 $this->name = 'feed_' . $filename;55 $this->mod_name = 'feed_mod_' . $filename;54 $this->name = 'feed_' . md5( "$filename:$extension" ); 55 $this->mod_name = 'feed_mod_' . md5( "$filename:$extension" ); 56 56 57 $lifetime = $this->lifetime; 58 /** 59 * Filters the transient lifetime of the feed cache. 60 * 61 * @since 2.8.0 62 * 63 * @param int $lifetime Cache duration in seconds. Default is 43200 seconds (12 hours). 64 * @param string $filename Unique identifier for the cache object. 65 */ 66 $this->lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', $lifetime, $filename ); 57 $options = $this->parse_location( $location ); 58 $this->lifetime = $options['extras']['lifetime']; 67 59 } 68 60 69 61 /** … … 129 121 delete_transient( $this->mod_name ); 130 122 return true; 131 123 } 124 125 /** 126 * Parse location. 127 * 128 * @since 5.5.0 129 * 130 * @param string $location URL location (scheme is used to determine handler). 131 * @return array location parameters 132 */ 133 public function parse_location( $location ) { 134 $params = parse_url( $location ); 135 $params['extras'] = array(); 136 if ( isset( $params['query'] ) ) 137 { 138 parse_str( $params['query'], $params['extras'] ); 139 } 140 return $params; 141 } 132 142 } -
wp-includes/class-wp-feed-cache.php
17 17 class WP_Feed_Cache extends SimplePie_Cache { 18 18 19 19 /** 20 * Cache handler class 21 * 22 * @var array 23 */ 24 protected static $handlers = array( 25 'wordpress' => 'WP_Feed_Cache_Transient', 26 ); 27 28 /** 20 29 * Creates a new SimplePie_Cache object. 21 30 * 22 31 * @since 2.8.0 … … 26 35 * @param string $extension 'spi' or 'spc'. 27 36 * @return WP_Feed_Cache_Transient Feed cache handler object that uses transients. 28 37 */ 29 public function create( $location, $filename, $extension ) {38 public static function get_handler( $location, $filename, $extension ) { 30 39 return new WP_Feed_Cache_Transient( $location, $filename, $extension ); 31 40 } 41 42 /** 43 * Creates a new SimplePie_Cache object. 44 * 45 * see get_handler() 46 */ 47 public function create( $location, $filename, $extension ) { 48 return self::get_handler($location, $filename, $extension); 49 } 32 50 } 51 -
wp-includes/feed.php
760 760 761 761 $feed = new SimplePie(); 762 762 763 $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' );764 // We must manually overwrite $feed->sanitize because SimplePie's765 // constructor sets it before we have a chance to set the sanitization class.766 $feed-> sanitize = new WP_SimplePie_Sanitize_KSES();763 // No need to overwrite $feed->sanitize anymore, SimplePie do it right now 764 $feed->registry->register( 'Sanitize', 'WP_SimplePie_Sanitize_KSES', true ); 765 $feed->registry->register( 'File', 'WP_SimplePie_File', true ); 766 $feed->registry->register( 'Cache', 'WP_Feed_Cache', true ); 767 767 768 $feed->set_cache_class( 'WP_Feed_Cache' ); 769 $feed->set_file_class( 'WP_SimplePie_File' ); 768 /** 769 * Filters the transient lifetime of the feed cache. 770 * 771 * @since 2.8.0 772 * 773 * @param int $lifetime Cache duration in seconds. Default is 12 hours. 774 * @param string $filename Unique identifier for the cache object. 775 */ 776 $lifetime = apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ); 770 777 778 $feed->set_cache_duration( $lifetime ); 779 $feed->set_cache_location( 'wordpress://transient?lifetime=' . $lifetime ); 771 780 $feed->set_feed_url( $url ); 772 /** This filter is documented in wp-includes/class-wp-feed-cache-transient.php */ 773 $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) ); 781 774 782 /** 775 783 * Fires just before processing the SimplePie feed object. 776 784 *