Ticket #1196 (closed defect: fixed)
Bug in _constructQueryFromCache, Result Cache does not work.
| Reported by: | mthielen | Owned by: | romanb |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | Caching | Version: | 1.0.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description (last modified by mthielen) (diff)
The Resultcache (in my case the APC version) does not work at all.
$cacheDriver = new Doctrine_Cache_Apc(); $manager = Doctrine_Manager::getInstance(); $manager->setAttribute(Doctrine::ATTR_QUERY_CACHE, $cacheDriver); $manager->setAttribute(Doctrine::ATTR_RESULT_CACHE, $cacheDriver);
...connecting...
for ($i = 0; $i < 500; $i++) {
$u = Doctrine_Query::create()
->from('User u')
->addWhere('u.Login=?', array('DemoUser'))
->execute();
}
The first query ($i=0) works as expected as it doesnt read from cache. But the 2nd results in this exception:
<b>Warning</b>: unserialize() expects parameter 1 to be string, array given in <b>J:ProgrammePHPPEARDoctrinelibDoctrineQueryAbstract.php</b> on line <b>1127</b><br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>J:ProgrammePHPPEARDoctrinelibDoctrineQueryAbstract.php</b> on line <b>1133</b><br />
<b>Fatal error</b>: Uncaught exception 'Doctrine_Query_Exception' with message 'Root component not initialized.' in J:ProgrammePHPPEARDoctrinelibDoctrineQueryAbstract.php:868
Stack trace:
#0 J:ProgrammePHPPEARDoctrinelibDoctrineQueryAbstract.php(568): Doctrine_Query_Abstract->getRoot()
#1 J:ProgrammePHPPEARDoctrinelibDoctrineQueryAbstract.php(963): Doctrine_Query_Abstract->convertEnums(Array)
#2 J:ProgrammePHPPEARDoctrinelibDoctrineQueryAbstract.php(1019): Doctrine_Query_Abstract->_execute(Array)
#3 W:PrivatJavaWebPortaldoctrine.php(30): Doctrine_Query_Abstract->execute()
#4 {main}
thrown in <b>J:ProgrammePHPPEARDoctrinelibDoctrineQueryAbstract.php</b> on line <b>868</b><br />
When patching the function Abstract.php like this:
protected function _constructQueryFromCache($cached)
{
if (is_array($cached))
$cached = $cached[0];
the error is gone but the resultcache doesnt work either. Nothing is written to APC nor read from.
Regards, Markus
Change History
Note: See
TracTickets for help on using
tickets.