Bug Report #4032

Logic in execute() results in no result queries being run again.

Added by Deon George about 3 years ago. Updated about 3 years ago.

Status:ClosedStart date:05/31/2011
Priority:NormalDue date:
Assignee:Chris Bandy% Done:

100%

Category:-
Target version:Kohana v3.x - v3.0.12
Resolution:fixed Points:

Description

In Kohana_Database_Query::execute(), there is a test to see if a query is in the cache.

if ($result = Kohana::cache($cache_key, NULL, $this->_lifetime))

If a previous run of a query resulted in no records being returned, on that previous run KH would have stored array() in the cache.

When the query is run a second time, there would be a cache hit, however, array() is returned, which evaluates to false, resulting in the query being run again anyway (and being cached again anyway).

If it is "normal" for a query to return no records, then it is not possible to cache that query result with the above logic.

Since Kohana::cache() returns NULL for a cache miss, I think the logic should be

if (! is_null($result = Kohana::cache($cache_key, NULL, $this->_lifetime)))

This is for KH 3.1.3.1.

...deon

Associated revisions

Revision e3533409
Added by Chris Bandy about 3 years ago

Handle cached empty results in Query::execute(). Fixes #4032

History

#1 Updated by Jeremy Bush about 3 years ago

  • Target version set to v3.1.4

#2 Updated by Chris Bandy about 3 years ago

  • Status changed from New to Closed
  • Assignee set to Chris Bandy
  • Target version changed from v3.1.4 to v3.0.12
  • % Done changed from 0 to 100
  • Resolution set to fixed

Also available in: Atom PDF