From fb0dcae7e7a31297ebd88d51e971bc2ffb5b5420 Mon Sep 17 00:00:00 2001
From: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date: Fri, 27 Apr 2018 20:12:50 -0500
Subject: [PATCH] [#29204] Fix errors about non-static WP_Feed_Cache::create
invocation
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
`WP_Feed_Cache_Transient`.
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,
both).
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
|
|
14 | 14 | * |
15 | 15 | * @see SimplePie_Cache |
16 | 16 | */ |
17 | | class WP_Feed_Cache extends SimplePie_Cache { |
| 17 | class WP_Feed_Cache { |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Creates a new SimplePie_Cache object. |
… |
… |
class WP_Feed_Cache extends SimplePie_Cache { |
26 | 26 | * @param string $extension 'spi' or 'spc'. |
27 | 27 | * @return WP_Feed_Cache_Transient Feed cache handler object that uses transients. |
28 | 28 | */ |
29 | | public function create( $location, $filename, $extension ) { |
| 29 | public static function create( $location, $filename, $extension ) { |
30 | 30 | return new WP_Feed_Cache_Transient( $location, $filename, $extension ); |
31 | 31 | } |
32 | 32 | } |