Make WordPress Core


Ignore:
Timestamp:
09/30/2024 10:48:16 PM (5 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/File.php

    r47733 r59141  
    11<?php
     2
    23/**
    34 * SimplePie
     
    67 * Takes the hard work out of managing a complete RSS/Atom solution.
    78 *
    8  * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
     9 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    910 * All rights reserved.
    1011 *
     
    4243 */
    4344
     45namespace SimplePie\Cache;
     46
    4447/**
    4548 * Caches data to the filesystem
     
    4750 * @package SimplePie
    4851 * @subpackage Caching
     52 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
    4953 */
    50 class SimplePie_Cache_File implements SimplePie_Cache_Base
     54class File implements Base
    5155{
    52     /**
    53     * Location string
    54     *
    55     * @see SimplePie::$cache_location
    56     * @var string
    57     */
    58     protected $location;
     56    /**
     57    * Location string
     58    *
     59    * @see SimplePie::$cache_location
     60    * @var string
     61    */
     62    protected $location;
    5963
    60     /**
    61     * Filename
    62     *
    63     * @var string
    64     */
    65     protected $filename;
     64    /**
     65    * Filename
     66    *
     67    * @var string
     68    */
     69    protected $filename;
    6670
    67     /**
    68     * File extension
    69     *
    70     * @var string
    71     */
    72     protected $extension;
     71    /**
     72    * File extension
     73    *
     74    * @var string
     75    */
     76    protected $extension;
    7377
    74     /**
    75     * File path
    76     *
    77     * @var string
    78     */
    79     protected $name;
     78    /**
     79    * File path
     80    *
     81    * @var string
     82    */
     83    protected $name;
    8084
    81     /**
    82     * Create a new cache object
    83     *
    84     * @param string $location Location string (from SimplePie::$cache_location)
    85     * @param string $name Unique ID for the cache
    86      * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
    87     */
    88     public function __construct($location, $name, $type)
    89     {
    90         $this->location = $location;
    91         $this->filename = $name;
    92         $this->extension = $type;
    93         $this->name = "$this->location/$this->filename.$this->extension";
    94     }
     85    /**
     86    * Create a new cache object
     87    *
     88    * @param string $location Location string (from SimplePie::$cache_location)
     89    * @param string $name Unique ID for the cache
     90     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
     91    */
     92    public function __construct($location, $name, $type)
     93    {
     94        $this->location = $location;
     95        $this->filename = $name;
     96        $this->extension = $type;
     97        $this->name = "$this->location/$this->filename.$this->extension";
     98    }
    9599
    96     /**
    97      * Save data to the cache
    98      *
    99      * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
    100      * @return bool Successfulness
    101      */
    102     public function save($data)
    103     {
    104         if (file_exists($this->name) && is_writable($this->name) || file_exists($this->location) && is_writable($this->location))
    105         {
    106             if ($data instanceof SimplePie)
    107             {
    108                 $data = $data->data;
    109             }
     100    /**
     101     * Save data to the cache
     102     *
     103     * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
     104     * @return bool Successfulness
     105     */
     106    public function save($data)
     107    {
     108        if (file_exists($this->name) && is_writable($this->name) || file_exists($this->location) && is_writable($this->location)) {
     109            if ($data instanceof \SimplePie\SimplePie) {
     110                $data = $data->data;
     111            }
    110112
    111             $data = serialize($data);
    112             return (bool) file_put_contents($this->name, $data);
    113         }
    114         return false;
    115     }
     113            $data = serialize($data);
     114            return (bool) file_put_contents($this->name, $data);
     115        }
     116        return false;
     117    }
    116118
    117     /**
    118      * Retrieve the data saved to the cache
    119      *
    120      * @return array Data for SimplePie::$data
    121      */
    122     public function load()
    123     {
    124         if (file_exists($this->name) && is_readable($this->name))
    125         {
    126             return unserialize(file_get_contents($this->name));
    127         }
    128         return false;
    129     }
     119    /**
     120     * Retrieve the data saved to the cache
     121     *
     122     * @return array Data for SimplePie::$data
     123     */
     124    public function load()
     125    {
     126        if (file_exists($this->name) && is_readable($this->name)) {
     127            return unserialize(file_get_contents($this->name));
     128        }
     129        return false;
     130    }
    130131
    131     /**
    132     * Retrieve the last modified time for the cache
    133     *
    134     * @return int Timestamp
    135     */
    136     public function mtime()
    137     {
    138         return @filemtime($this->name);
    139     }
     132    /**
     133    * Retrieve the last modified time for the cache
     134    *
     135    * @return int Timestamp
     136    */
     137    public function mtime()
     138    {
     139        return @filemtime($this->name);
     140    }
    140141
    141     /**
    142     * Set the last modified time to the current time
    143     *
    144     * @return bool Success status
    145     */
    146     public function touch()
    147     {
    148         return @touch($this->name);
    149     }
     142    /**
     143    * Set the last modified time to the current time
     144    *
     145    * @return bool Success status
     146    */
     147    public function touch()
     148    {
     149        return @touch($this->name);
     150    }
    150151
    151     /**
    152      * Remove the cache
    153      *
    154      * @return bool Success status
    155      */
    156     public function unlink()
    157     {
    158         if (file_exists($this->name))
    159         {
    160             return unlink($this->name);
    161         }
    162         return false;
    163     }
     152    /**
     153     * Remove the cache
     154     *
     155     * @return bool Success status
     156     */
     157    public function unlink()
     158    {
     159        if (file_exists($this->name)) {
     160            return unlink($this->name);
     161        }
     162        return false;
     163    }
    164164}
     165
     166class_alias('SimplePie\Cache\File', 'SimplePie_Cache_File');
Note: See TracChangeset for help on using the changeset viewer.