Bug Report #4032
Logic in execute() results in no result queries being run again.
|Assignee:||Chris Bandy||% Done:|
|Target version:||Kohana v3.x - v3.0.12|
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 18.104.22.168.