Make WordPress Core

Changeset 49565

Timestamp:
11/12/2020 02:34:33 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Feeds: Register transient feed cache handler using the recommended method for SimplePie 1.3 or later.

This fixes a "Non-static method cannot be called statically" fatal error when calling fetch_feed() on PHP 8.

Follow-up to [21644], [21652], [22366], [22599].

Props dd32, afragen, Senning, markoheijnen, ComputerGuru, useStrict, Ipstenu, nacin, l3rady, HoaSi, NathanAtmoz, fabifott, jfoulquier, thefarlilacfield, subscriptiongroup, rogerlos, Mte90, mopsyd, dossy, stulab, MadtownLems, roikles, justlevine, joostdevalk, OptimizingMatters, hellofromTonya, bph, ayeshrajans, SergeyBiryukov.
Fixes #29204.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r42343 r49565  
    66 * @subpackage Feed
    77 * @since 4.7.0
     8
    89 */
     10
     11
     12
     13
     14
     15
     16
    917
    1018/**
  • trunk/src/wp-includes/feed.php

    r48435 r49565  
    790790    }
    791791
    792     require_once ABSPATH . WPINC . '/class-wp-feed-cache.php';
    793792    require_once ABSPATH . WPINC . '/class-wp-feed-cache-transient.php';
    794793    require_once ABSPATH . WPINC . '/class-wp-simplepie-file.php';
     
    802801    $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
    803802
    804     $feed->set_cache_class( 'WP_Feed_Cache' );
     803    // Register the cache handler using the recommended method for SimplePie 1.3 or later.
     804    if ( method_exists( 'SimplePie_Cache', 'register' ) ) {
     805        SimplePie_Cache::register( 'wp_transient', 'WP_Feed_Cache_Transient' );
     806        $feed->set_cache_location( 'wp_transient' );
     807    } else {
     808        // Back-compat for SimplePie 1.2.x.
     809        require_once ABSPATH . WPINC . '/class-wp-feed-cache.php';
     810        $feed->set_cache_class( 'WP_Feed_Cache' );
     811    }
     812
    805813    $feed->set_file_class( 'WP_SimplePie_File' );
    806814
Note: See TracChangeset for help on using the changeset viewer.