[wp-trac] [WordPress Trac] #43514: `get_pages()` DB query result not cached if nothing found

WordPress Trac noreply at wordpress.org
Fri Mar 9 20:58:21 UTC 2018


#43514: `get_pages()` DB query result not cached if nothing found
--------------------------+------------------------------------------
 Reporter:  flixos90      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:
 Severity:  normal        |   Keywords:  needs-patch needs-unit-tests
  Focuses:                |
--------------------------+------------------------------------------
 `get_pages()` uses a cache key in order to not have to query the DB when
 it's not necessary. However, if the DB query returns an empty result, that
 result is not cached, causing that DB query to be executed every time the
 function is called with these parameters.

 Since the function uses `wp_cache_get_last_changed( 'posts' )` anyway, it
 should be safe to also set an empty array if nothing is found, to prevent
 those unnecessary database requests.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43514>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list