[wp-trac] [WordPress Trac] #16336: wpdb::get_row never uses the cache
WordPress Trac
wp-trac at lists.automattic.com
Fri Jan 21 22:52:29 UTC 2011
#16336: wpdb::get_row never uses the cache
-------------------------+------------------------------
Reporter: Lacrymology | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version:
Severity: normal | Resolution:
Keywords: close |
-------------------------+------------------------------
Changes (by scribu):
* keywords: => close
* component: General => Database
Old description:
> wpdb::get_row never uses the cached results, look at this
>
> function get_row( $query = null, $output = OBJECT, $y = 0 ) {
> $this->func_call =
> "\$db->get_row(\"$query\",$output,$y)";
> if ( $query )
> $this->query( $query );
> else
> return null;
> // more code
>
> and then
>
> function query( $query ) {
> if ( ! $this->ready )
> return false;
>
> // some queries are made before the plugins have been
> loaded, and thus cannot be filtered with this method
> if ( function_exists( 'apply_filters' ) )
> $query = apply_filters( 'query', $query );
>
> $return_val = 0;
> $this->flush();
>
> See how the cache never gets called? if you write a query, the old one
> gets flushed without checking if it was the same as before, if you use
> null, null gets returned, an if($this->last_query != $query) needs to be
> put in ::query or the return null removed from ::get_row, I'd prefer the
> first solution.
New description:
wpdb::get_row never uses the cached results, look at this
{{{
function get_row( $query = null, $output = OBJECT, $y = 0 ) {
$this->func_call = "\$db->get_row(\"$query\",$output,$y)";
if ( $query )
$this->query( $query );
else
return null;
// more code
}}}
and then
{{{
function query( $query ) {
if ( ! $this->ready )
return false;
// some queries are made before the plugins have been
loaded, and thus cannot be filtered with this method
if ( function_exists( 'apply_filters' ) )
$query = apply_filters( 'query', $query );
$return_val = 0;
$this->flush();
}}}
See how the cache never gets called? if you write a query, the old one
gets flushed without checking if it was the same as before, if you use
null, null gets returned, an if($this->last_query != $query) needs to be
put in ::query or the return null removed from ::get_row, I'd prefer the
first solution.
--
Comment:
The caching is done on top of WPDB, not through it.
Also, what about DML queries? (INSERT, DELETE etc.)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16336#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list