Make WordPress Core

Changeset 60490


Ignore:
Timestamp:
07/21/2025 01:39:41 AM (11 hours ago)
Author:
peterwilsoncc
Message:

External Libraries: Upgrade Simple Pie to 1.8.1 (patched).

Upgrades the Simple Pie library to a patched version of Simple Pie 1.8.1. Much of 1.8.1 was included in the 1.8.0 upgrade committed in r59141. The following fixes from the latest release those that remain for this upgrade:

A caching fix not included in Simple Pie 1.8.1 is also included in this upgrade, see simplepie/simplepie#883.

A caching test for fetch_feed() is introduced in this pull request to ensure that the caching patch is included in future upgrades of the library.

Props kaygee79, oglekler, SergeyBiryukov, peterwilsoncc.
Fixes #63717.

Location:
trunk
Files:
2 deleted
2 edited

Legend:

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

    r59141 r60490  
    7171     * SimplePie Version
    7272     */
    73     public const VERSION = '1.8.0';
     73    public const VERSION = '1.8.1';
    7474
    7575    /**
     
    13741374        $this->sanitize->strip_htmltags($tags);
    13751375        if ($encode !== null) {
    1376             $this->sanitize->encode_instead_of_strip($tags);
     1376            $this->sanitize->encode_instead_of_strip($encode);
    13771377        }
    13781378    }
     
    17571757                }
    17581758                // Check if the cache has been updated
    1759                 elseif (isset($this->data['cache_expiration_time']) && $this->data['cache_expiration_time'] > time()) {
     1759                elseif (!isset($this->data['cache_expiration_time']) || $this->data['cache_expiration_time'] < time()) {
    17601760                    // Want to know if we tried to send last-modified and/or etag headers
    17611761                    // when requesting this file. (Note that it's up to the file to
     
    18321832            if (!$locate->is_feed($file)) {
    18331833                $copyStatusCode = $file->status_code;
    1834                 $copyContentType = $file->headers['content-type'];
     1834                $copyContentType = $file->headers['content-type'] ?? '';
    18351835                try {
    18361836                    $microformats = false;
  • trunk/tests/phpunit/tests/feed/fetchFeed.php

    r59408 r60490  
    3434    }
    3535
     36    /**
     37     * Ensure that fetch_feed() is cached on second and subsequent calls.
     38     *
     39     * Note: The HTTP request is mocked on the `pre_http_request` filter so
     40     * this test doesn't make any HTTP requests so it doesn't need to be
     41     * placed in the external-http group.
     42     *
     43     * @ticket 63717
     44     *
     45     * @group feed
     46     *
     47     * @covers ::fetch_feed
     48     */
     49    public function test_fetch_feed_cached() {
     50        $filter = new MockAction();
     51        add_filter( 'pre_http_request', array( $filter, 'filter' ) );
     52
     53        fetch_feed( 'https://wordpress.org/news/feed/' );
     54        $this->assertEquals( 1, $filter->get_call_count(), 'The feed should be fetched on the first call.' );
     55
     56        fetch_feed( 'https://wordpress.org/news/feed/' );
     57        $this->assertEquals( 1, $filter->get_call_count(), 'The feed should be cached on the second call. For SP 1.8.x upgrades, backport simplepie/simplepie#830 to resolve.' );
     58    }
     59
     60    /**
     61     * Mock response for `fetch_feed()`.
     62     *
     63     * This simulates a response from WordPress.org's server for the news feed
     64     * to avoid making actual HTTP requests during the tests.
     65     *
     66     * The method runs on the `pre_http_request` filter, a low level filter
     67     * to allow developers to determine whether a request would have been made
     68     * under normal circumstances.
     69     *
     70     * @return array Mocked response data.
     71     */
    3672    public function mocked_rss_response() {
    3773        $single_value_headers = array(
Note: See TracChangeset for help on using the changeset viewer.