Make WordPress Core

Changeset 21652


Ignore:
Timestamp:
08/29/2012 12:25:52 AM (12 years ago)
Author:
nacin
Message:

Stabilize how WordPress hooks into SimplePie to implement transient caching.

Since a plugin can load a previous (< 1.3) version of SimplePie before we do,
we need to be compatible with our old method of overriding SimplePie_Cache::create().

SimplePie_Cache::create() was converted to static in 1.3 (as it was called),
requiring that we create two different definitions of WP_Feed_Cache (extends
SimplePie_Cache). Instead, we can use 1.3's new object registry, and leave
the old WP_Feed_Cache to SimplePie 1.2 versions.

see #21183.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-feed.php

    r21644 r21652  
    44    require_once (ABSPATH . WPINC . '/class-simplepie.php');
    55
    6 class WP_Feed_Cache extends SimplePie_Cache {
    7     /**
    8      * Create a new SimplePie_Cache object
    9      *
    10      * @static
    11      * @access public
    12      */
    13     public static function create($location, $filename, $extension) {
    14         return new WP_Feed_Cache_Transient($location, $filename, $extension);
     6if ( version_compare( SIMPLEPIE_VERSION, '1.3-dev', '>' ) ) :
     7    SimplePie_Cache::register( 'wp-transient', 'WP_Feed_Cache_Transient' );
     8else :
     9    class WP_Feed_Cache extends SimplePie_Cache {
     10        /**
     11         * Create a new SimplePie_Cache object
     12         *
     13         * @static
     14         * @access public
     15         */
     16        function create($location, $filename, $extension) {
     17            return new WP_Feed_Cache_Transient($location, $filename, $extension);
     18        }
    1519    }
    16 }
     20endif;
    1721
    1822class WP_Feed_Cache_Transient {
  • trunk/wp-includes/feed.php

    r21239 r21652  
    533533
    534534    $feed = new SimplePie();
     535
     536    if ( version_compare( SIMPLEPIE_VERSION, '1.3-dev', '>' ) ) {
     537        $feed->set_cache_location( 'wp-transient' );
     538        $feed->registry->register( 'Cache', 'WP_Feed_Cache_Transient' );
     539        $feed->registry->register( 'File', 'WP_SimplePie_File' );
     540    } else {
     541        $feed->set_cache_class( 'WP_Feed_Cache' );
     542        $feed->set_file_class( 'WP_SimplePie_File' );
     543    }
     544
    535545    $feed->set_feed_url($url);
    536     $feed->set_cache_class('WP_Feed_Cache');
    537     $feed->set_file_class('WP_SimplePie_File');
    538546    $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));
    539547    do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
Note: See TracChangeset for help on using the changeset viewer.