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/Memcached.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
     47use Memcached as NativeMemcached;
     48
    4449/**
    4550 * Caches data to memcached
     
    5560 * @author     Paul L. McNeely
    5661 * @uses       Memcached
     62 * @deprecated since SimplePie 1.8.0, use implementation of "Psr\SimpleCache\CacheInterface" instead
    5763 */
    58 class SimplePie_Cache_Memcached implements SimplePie_Cache_Base
     64class Memcached implements Base
    5965{
    6066    /**
    61      * Memcached instance
    62      * @var Memcached
     67     * NativeMemcached instance
     68     * @var NativeMemcached
    6369     */
    6470    protected $cache;
     
    7985     * Create a new cache object
    8086     * @param string $location Location string (from SimplePie::$cache_location)
    81      * @param string $name     Unique ID for the cache
    82      * @param string $type    Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
     87     * @param string $name Unique ID for the cache
     88     * @param Base::TYPE_FEED|Base::TYPE_IMAGE $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
    8389     */
    84     public function __construct($location, $name, $type) {
    85         $this->options = array(
     90    public function __construct($location, $name, $type)
     91    {
     92        $this->options = [
    8693            'host'   => '127.0.0.1',
    8794            'port'   => 11211,
    88             'extras' => array(
     95            'extras' => [
    8996                'timeout' => 3600, // one hour
    9097                'prefix'  => 'simplepie_',
    91             ),
    92         );
    93         $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));
     98            ],
     99        ];
     100        $this->options = array_replace_recursive($this->options, \SimplePie\Cache::parse_URL($location));
    94101
    95102        $this->name = $this->options['extras']['prefix'] . md5("$name:$type");
    96103
    97         $this->cache = new Memcached();
     104        $this->cache = new NativeMemcached();
    98105        $this->cache->addServer($this->options['host'], (int)$this->options['port']);
    99106    }
     
    101108    /**
    102109     * Save data to the cache
    103      * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
     110     * @param array|\SimplePie\SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
    104111     * @return bool Successfulness
    105112     */
    106     public function save($data) {
    107         if ($data instanceof SimplePie) {
     113    public function save($data)
     114    {
     115        if ($data instanceof \SimplePie\SimplePie) {
    108116            $data = $data->data;
    109117        }
     
    116124     * @return array Data for SimplePie::$data
    117125     */
    118     public function load() {
     126    public function load()
     127    {
    119128        $data = $this->cache->get($this->name);
    120129
     
    129138     * @return int Timestamp
    130139     */
    131     public function mtime() {
     140    public function mtime()
     141    {
    132142        $data = $this->cache->get($this->name . '_mtime');
    133143        return (int) $data;
     
    138148     * @return bool Success status
    139149     */
    140     public function touch() {
     150    public function touch()
     151    {
    141152        $data = $this->cache->get($this->name);
    142153        return $this->setData($data);
     
    147158     * @return bool Success status
    148159     */
    149     public function unlink() {
     160    public function unlink()
     161    {
    150162        return $this->cache->delete($this->name, 0);
    151163    }
    152164
    153165    /**
    154      * Set the last modified time and data to Memcached
     166     * Set the last modified time and data to NativeMemcached
    155167     * @return bool Success status
    156168     */
    157     private function setData($data) {
    158 
     169    private function setData($data)
     170    {
    159171        if ($data !== false) {
    160172            $this->cache->set($this->name . '_mtime', time(), (int)$this->options['extras']['timeout']);
     
    165177    }
    166178}
     179
     180class_alias('SimplePie\Cache\Memcached', 'SimplePie_Cache_Memcached');
Note: See TracChangeset for help on using the changeset viewer.