Make WordPress Core

Ticket #29204: 0001-29204-Fix-errors-about-non-static-WP_Feed_Cache-crea.2.patch

File 0001-29204-Fix-errors-about-non-static-WP_Feed_Cache-crea.2.patch, 2.1 KB (added by ComputerGuru, 6 years ago)

Updated patch and validated against trunk.

  • wp-includes/class-wp-feed-cache.php

    From fb0dcae7e7a31297ebd88d51e971bc2ffb5b5420 Mon Sep 17 00:00:00 2001
    From: Mahmoud Al-Qudsi <>
    Date: Fri, 27 Apr 2018 20:12:50 -0500
    Subject: [PATCH] [#29204] Fix errors about non-static WP_Feed_Cache::create
    SimplePie requires callbacks to be static functions as it cannot bind to
    an instance of a class. There's no problem since the WordPress funtion
    `WP_Feed_Cache::create` is a factory method that returns an instance of
    This method should be marked as `static` to avoid this error (and
    because it makes no sense for it not to be). Unfortunately, SimplePie's
    own default cache instance does not have the `static` attribute, and the
    function name `create` is hard-coded in SimplePie's `Registry.php`,
    meaning that re-declaring `create` as `static` in `WP_Feed_Cache` will
    throw an error about "making a non-static method static".
    However, there's no need for `WP_Feed_Cache` to actually derive from
    `SimplePie_Cache`, as its job is to actually just return an instance of
    an object implementing the `SimplePie_Cache_Base` interface, and this is
    literally the only call to it in the entire codebase (WP and SimplePie,
    Closes #29204.
     wp-includes/class-wp-feed-cache.php | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    diff --git a/wp-includes/class-wp-feed-cache.php b/wp-includes/class-wp-feed-cache.php
    index 2564dffb80..aad0143fb1 100644
    a b  
    1414 *
    1515 * @see SimplePie_Cache
    1616 */
    17 class WP_Feed_Cache extends SimplePie_Cache {
     17class WP_Feed_Cache {
    1919        /**
    2020         * Creates a new SimplePie_Cache object.
    class WP_Feed_Cache extends SimplePie_Cache { 
    2626         * @param string $extension 'spi' or 'spc'.
    2727         * @return WP_Feed_Cache_Transient Feed cache handler object that uses transients.
    2828         */
    29         public function create( $location, $filename, $extension ) {
     29        public static function create( $location, $filename, $extension ) {
    3030                return new WP_Feed_Cache_Transient( $location, $filename, $extension );
    3131        }