Bug Report #4032
Logic in execute() results in no result queries being run again.
| Status: | Closed | Start date: | 05/31/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % 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
Handle cached empty results in Query::execute(). Fixes #4032
History
Updated by Jeremy Bush 12 months ago
- Target version set to v3.1.4
Updated by Chris Bandy 11 months 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