Bug Report #4032

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

Added by Deon George almost 4 years ago. Updated over 3 years ago.

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


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


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


Associated revisions

Revision e3533409
Added by Chris Bandy over 3 years ago

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


#1 Updated by Jeremy Bush almost 4 years ago

  • Target version set to v3.1.4

#2 Updated by Chris Bandy over 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