[wp-trac] [WordPress Trac] #63717: `fetch_feed()` fails to use data stored in transients.
WordPress Trac
noreply at wordpress.org
Thu Jul 17 23:45:13 UTC 2025
#63717: `fetch_feed()` fails to use data stored in transients.
--------------------------------+------------------------------
Reporter: peterwilsoncc | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: External Libraries | Version:
Severity: normal | Resolution:
Keywords: | Focuses: performance
--------------------------------+------------------------------
Description changed by peterwilsoncc:
Old description:
> Since the SimplePie upgrade in r59141 / [https://github.com/wordpress
> /wordpress-develop/commit/ebfb7649ca168d585eda8be789db3817c439c585
> ebfb7649ca16]
>
> The `fetch_feed()` function is intended to store a cache of the feed in a
> transient and use the data for 12 hours.
>
> Since the upgrade the data is being stored as a transient but fails to
> make use of the data in subsequent requests to the feed. This results in
> each request to a website making use of the RSS block re-requesting the
> data on each page load.
>
> Reviewing the database, it appears the data is stored in a transient but
> the transient is ignored. The following test demonstrates the issue:
>
> {{{#!php
> <?php
> /**
> * Ensure that fetch_feed() is cached on second and subsequent calls.
> *
> * @group feed
> *
> * @covers ::fetch_feed
> */
> public function test_fetch_feed_cached() {
> $filter = new MockAction();
> add_filter( 'pre_http_request', array( $filter, 'filter' ) );
>
> fetch_feed( 'https://wordpress.org/news/feed/' );
> $this->assertSame( 1, $filter->get_call_count(), 'The feed should
> be fetched on the first call.' );
>
> fetch_feed( 'https://wordpress.org/news/feed/' );
> $this->assertSame( 1, $filter->get_call_count(), 'The feed should
> be cached on the second call.' );
> }
> }}}
>
> Note: when added to the test suite, this should be placed in the
> `external-http` group.
New description:
Since the SimplePie upgrade in r59141 / [https://github.com/wordpress
/wordpress-develop/commit/ebfb7649ca168d585eda8be789db3817c439c585
ebfb7649ca16]
The `fetch_feed()` function is intended to store a cache of the feed in a
transient and use the data for 12 hours.
Since the upgrade the data is being stored as a transient but fails to
make use of the data in subsequent requests to the feed. This results in
each request to a website making use of the RSS block re-requesting the
data on each page load.
Reviewing the database, it appears the data is stored in a transient but
the transient is ignored. The following test demonstrates the issue:
{{{#!php
<?php
/**
* Ensure that fetch_feed() is cached on second and subsequent calls.
*
* @group feed
*
* @covers ::fetch_feed
*/
public function test_fetch_feed_cached() {
$filter = new MockAction();
add_filter( 'pre_http_request', array( $filter, 'filter' ) );
fetch_feed( 'https://wordpress.org/news/feed/' );
$this->assertSame( 1, $filter->get_call_count(), 'The feed should
be fetched on the first call.' );
fetch_feed( 'https://wordpress.org/news/feed/' );
$this->assertSame( 1, $filter->get_call_count(), 'The feed should
be cached on the second call.' );
}
}}}
~~Note: when added to the test suite, this should be placed in the
`external-http` group.~~ ''The response can be mocked on the
`pre_http_request` filter''
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63717#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list