[wp-trac] [WordPress Trac] #49446: cache the results of get_uploaded_header_images()
WordPress Trac
noreply at wordpress.org
Tue Oct 14 23:17:44 UTC 2025
#49446: cache the results of get_uploaded_header_images()
-------------------------------------+-------------------------------------
Reporter: pbiron | Owner: pbearne
Type: enhancement | Status: reviewing
Priority: normal | Milestone: 6.9
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit- | Focuses: administration,
tests | performance
-------------------------------------+-------------------------------------
Comment (by peterwilsoncc):
@pbearne I'm not seeing any benefit here. Running
`test_get_uploaded_header_images_caches` on trunk passes as the number of
database queries are identical after the second call to the function.
The following test passes on trunk but fails on the PR as the number of
database queries increases on the feature branch (from 1 to 2).
{{{#!php
<?php
public function test_get_uploaded_header_images_queries() {
$start_num_queries = get_num_queries();
get_uploaded_header_images();
$this->assertSame( 1, get_num_queries() - $start_num_queries,
'first' );
get_uploaded_header_images();
$this->assertSame( 1, get_num_queries() - $start_num_queries,
'second' );
}
}}}
As `WP_Query` and therefore `get_posts()` are now cached, I think this
ticket is obsolete and can be resolved by removing the todo comment.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49446#comment:43>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list