Make WordPress Core


Ignore:
Timestamp:
09/30/2024 10:48:16 PM (4 months ago)
Author:
SergeyBiryukov
Message:

External Libraries: Update the SimplePie library to version 1.8.0.

The most notable change in this update is that all code is now namespaced and uses PSR-4 classes, though there is a compatibility layer available for extenders using the older class names, so plugin or theme authors directly using SimplePie can decide for themselves when they want to change to using the namespaced names for SimplePie classes.

Note: This commit includes additional fixes for PHP 8.4 compatibility (PR 875, PR 888) from the one-dot-eight branch of SimplePie, which is expected to be released as SimplePie 1.8.1 soon.

References:

Follow-up to [47733], [49176], [52393], [52413].

Props jrf, peterwilsoncc, chaion07, cu121, markparnell, audrasjb, costdev, Presskopp, desrosj, faisal03, mukesh27, SergeyBiryukov.
See #55604.

Location:
trunk/src/wp-includes/SimplePie/src
Files:
1 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/SimplePie/src/Cache/Redis.php

    r52393 r59141  
    22
    33/**
    4  * SimplePie Redis Cache Extension
     4 * SimplePie
     5 *
     6 * A PHP-Based RSS and Atom Feed Framework.
     7 * Takes the hard work out of managing a complete RSS/Atom solution.
     8 *
     9 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
     10 * All rights reserved.
     11 *
     12 * Redistribution and use in source and binary forms, with or without modification, are
     13 * permitted provided that the following conditions are met:
     14 *
     15 *  * Redistributions of source code must retain the above copyright notice, this list of
     16 *    conditions and the following disclaimer.
     17 *
     18 *  * Redistributions in binary form must reproduce the above copyright notice, this list
     19 *    of conditions and the following disclaimer in the documentation and/or other materials
     20 *    provided with the distribution.
     21 *
     22 *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
     23 *    to endorse or promote products derived from this software without specific prior
     24 *    written permission.
     25 *
     26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
     27 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
     28 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
     29 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     33 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34 * POSSIBILITY OF SUCH DAMAGE.
    535 *
    636 * @package SimplePie
    7  * @author Jan Kozak <galvani78@gmail.com>
    8  * @link http://galvani.cz/
     37 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
     38 * @author Ryan Parman
     39 * @author Sam Sneddon
     40 * @author Ryan McCue
     41 * @link http://simplepie.org/ SimplePie
    942 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    10  * @version 0.2.9
    1143 */
    1244
     45namespace SimplePie\Cache;
     46
     47use Redis as NativeRedis;
    1348
    1449/**
     
    2459 * @subpackage Caching
    2560 * @uses Redis
     61 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
    2662 */
    27 class SimplePie_Cache_Redis implements SimplePie_Cache_Base {
     63class Redis implements Base
     64{
    2865    /**
    2966     * Redis instance
    3067     *
    31      * @var \Redis
     68     * @var NativeRedis
    3269     */
    3370    protected $cache;
     
    4683     */
    4784    protected $name;
    48 
    49     /**
    50      * Cache Data
    51      *
    52      * @var type
    53      */
    54     protected $data;
    5585
    5686    /**
     
    5989     * @param string $location Location string (from SimplePie::$cache_location)
    6090     * @param string $name Unique ID for the cache
    61      * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
    62      */
    63     public function __construct($location, $name, $options = null) {
     91     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
     92     */
     93    public function __construct($location, $name, $options = null)
     94    {
    6495        //$this->cache = \flow\simple\cache\Redis::getRedisClientInstance();
    65         $parsed = SimplePie_Cache::parse_URL($location);
    66         $redis = new Redis();
     96        $parsed = \SimplePie\Cache::parse_URL($location);
     97        $redis = new NativeRedis();
    6798        $redis->connect($parsed['host'], $parsed['port']);
    6899        if (isset($parsed['pass'])) {
     
    77108            $this->options = $options;
    78109        } else {
    79             $this->options = array (
     110            $this->options = [
    80111                'prefix' => 'rss:simple_primary:',
    81112                'expire' => 0,
    82             );
     113            ];
    83114        }
    84115
     
    87118
    88119    /**
    89      * @param \Redis $cache
    90      */
    91     public function setRedisClient(\Redis $cache) {
     120     * @param NativeRedis $cache
     121     */
     122    public function setRedisClient(NativeRedis $cache)
     123    {
    92124        $this->cache = $cache;
    93125    }
     
    96128     * Save data to the cache
    97129     *
    98      * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
     130     * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
    99131     * @return bool Successfulness
    100132     */
    101     public function save($data) {
    102         if ($data instanceof SimplePie) {
     133    public function save($data)
     134    {
     135        if ($data instanceof \SimplePie\SimplePie) {
    103136            $data = $data->data;
    104137        }
     
    116149     * @return array Data for SimplePie::$data
    117150     */
    118     public function load() {
     151    public function load()
     152    {
    119153        $data = $this->cache->get($this->name);
    120154
     
    130164     * @return int Timestamp
    131165     */
    132     public function mtime() {
    133 
     166    public function mtime()
     167    {
    134168        $data = $this->cache->get($this->name);
    135169
     
    146180     * @return bool Success status
    147181     */
    148     public function touch() {
    149 
     182    public function touch()
     183    {
    150184        $data = $this->cache->get($this->name);
    151185
     
    166200     * @return bool Success status
    167201     */
    168     public function unlink() {
     202    public function unlink()
     203    {
    169204        return $this->cache->set($this->name, null);
    170205    }
    171 
    172206}
     207
     208class_alias('SimplePie\Cache\Redis', 'SimplePie_Cache_Redis');
Note: See TracChangeset for help on using the changeset viewer.