Skip to content

Commit

Permalink
[mms] Fix boostrapping DB object when using SQL as the Horde cache dr…
Browse files Browse the repository at this point in the history
…iver (Bug #13439).
  • Loading branch information
slusarz committed Aug 16, 2014
1 parent 29bf22b commit d1e573e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
43 changes: 22 additions & 21 deletions framework/Core/lib/Horde/Core/Factory/Db.php
Expand Up @@ -99,7 +99,14 @@ public function create($app = 'horde', $backend = null)
$this->_instances[$sig] = $this->create();
} elseif (!isset($this->_instances[$sig])) {
try {
$this->_instances[$sig] = $this->createDb($config);
$this->_instances[$sig] = $this->_createDb($config);
if (!isset($config['cache'])) {
/* Need to add cache ob here, instead of createDb, or else
* we enter infinite bootstrapping loop. Bug #13439 */
$this->_instances[$sig]->setCache(
$this->_injector->getInstance('Horde_Cache')
);
}
} catch (Horde_Exception $e) {}
}

Expand All @@ -124,14 +131,25 @@ public function getConfig($backend)
/**
*/
public function createDb($config)
{
$ob = $this->_createDb($config);
if (!isset($config['cache'])) {
$ob->setCache($this->_injector->getInstance('Horde_Cache'));
}
return $ob;
}

/**
*/
protected function _createDb($config)
{
// Split read?
if (!empty($config['splitread'])) {
$read_config = $config['read'];
unset($config['read'], $config['splitread']);
return new Horde_Db_Adapter_SplitRead(
$this->createDb(array_merge($config, $read_config)),
$this->createDb($config)
$this->_createDb(array_merge($config, $read_config)),
$this->_createDb($config)
);
}

Expand Down Expand Up @@ -169,28 +187,11 @@ public function createDb($config)

$ob = new $class($config);

if (!isset($config['cache'])) {
$cacheFactory = $this->_injector->getInstance('Horde_Core_Factory_Cache');

switch ($cacheFactory->getDriverName()) {
case 'sql':
$injector = $this->_injector->createChildInjector();
$injector->setInstance('Horde_Db_Adapter', $ob);
$cache = $cacheFactory->create($injector);
break;

default:
$cache = $this->_injector->getInstance('Horde_Cache');
break;
}

$ob->setCache($cache);
}

if (!isset($config['logger'])) {
$ob->setLogger($this->_injector->getInstance('Horde_Log_Logger'));
}

return $ob;
}

}
2 changes: 2 additions & 0 deletions framework/Core/package.xml
Expand Up @@ -39,6 +39,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Fix boostrapping DB object when using SQL as the Horde cache driver (Bug #13439).
* [mjr] Support ITEMOPERATIONS_EMPTYFOLDER requests via ActiveSync.
* [mjr] Fetch correct data for EAS ItemSettings requests.
* [jan] Catch exception from application in portal block (Bug #13427).
Expand Down Expand Up @@ -3603,6 +3604,7 @@
<date>2014-08-04</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Fix boostrapping DB object when using SQL as the Horde cache driver (Bug #13439).
* [mjr] Support ITEMOPERATIONS_EMPTYFOLDER requests via ActiveSync.
* [mjr] Fetch correct data for EAS ItemSettings requests.
* [jan] Catch exception from application in portal block (Bug #13427).
Expand Down

0 comments on commit d1e573e

Please sign in to comment.