Summary | Using SQL sessionhandler and SQL cache causes infinite recursion |
Queue | Horde Base |
Queue Version | Git master |
Type | Bug |
State | Resolved |
Priority | 1. Low |
Owners | Horde Developers (at) |
Requester | bklang (at) horde (dot) org |
Created | 10/02/2010 (5398 days ago) |
Due | |
Updated | 01/24/2011 (5284 days ago) |
Assigned | 10/05/2010 (5395 days ago) |
Resolved | 01/24/2011 (5284 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | 4 |
Patch | No |
State ⇒ Resolved
Bug #9282: When creating Horde_Db objects, register them with a childinjector before creating any dependencies that could in turn want a
Horde_Db dependency.
http://git.horde.org/horde-git/-/commit/fa4fbb47bf73abd59ae6d690fb25594576acfe16
when the logger is configured to log using Horde_Db is always going to
create an infinite loop, even if we get past the object construction
phase.
instance? On dev@ I was discussing the use of a queued logger during
the time before the log object itself was available (e.g. before the
Horde config could be parsed). But a queued logger could likewise be
used in this instance - log requests to the logger are queued until
the logger can determine that the backend (the DB object) is fully
initialized.
being that logger and cache shouldn't be getting a full-fledged
Horde_Db_Adapter, or that Horde_Db_Adapter shouldn't include logging
and caching, but a higher-level object should. From the comments at
http://misko.hevery.com/2008/08/01/circular-dependency-in-constructors-and-dependency-injection/:
@Peter,
here is how I would attack you problem.
class Database() implements DB;
class Logger(Database db);
class LoggingDatabase(Logger log, Database db) implements DB;
DB rawDatabase = new Database();
Logger log = new Logger(rowDatabase);
DB dbForTheRestoOfApplication = new LoggingDatabase(log, rowDatabase);
There you go. LoggingDatabase logs the commands as they go by and than
delegate it on a class of the same interface. This is know as chain of
responsibility and it is my favorite design pattern.
... so, that seems clean, but will take a little work.
is using Db storage -> the Db is creating a cache object to store
things like Db schema info -> the cache is stored in the Db itself.
Looks like we need some way to pass the cache object to the Db before
it is instantiated. I'm guessing this might be a place to use
injector/factories(?)
The solution is to add the logger to the object after creating it via
a setLogger() call instead of in the constructor.
Assigned to
Milestone ⇒ 4
Priority ⇒ 1. Low
Type ⇒ Bug
Summary ⇒ Using SQL sessionhandler and SQL cache causes infinite recursion
Queue ⇒ Horde Base
Milestone ⇒
Patch ⇒ No
State ⇒ Unconfirmed
1 0.0016 795432 {main}( ) ../config.php:0
2 0.1231 2465768 Horde_Registry::appInit( ) ../config.php:12
3 0.1231 2468832 Horde_Registry->__construct( ) ../Registry.php:207
4 0.1495 3447712 Horde_Registry->setupSessionHandler( ) ../Registry.php:415
5 0.1496 3449360 Horde_Injector->createInstance( ) ../Registry.php:1657
6 0.1507 3488920 Horde_Core_Binder_SessionHandler->create(
) ../Injector.php:261
7 0.1515 3544704 Horde_Core_Factory_Db->getDb( ) ../SessionHandler.php:23
8 0.1516 3546296 Horde_Core_Factory_Db->getDb( ) ../Db.php:86
9 0.1516 3547576 Horde_Core_Factory_Db->_createDb( ) ../Db.php:91
10 0.1586 4322088 Horde_Injector->getInstance( ) ../Db.php:155
11 0.1586 4322088 Horde_Injector->createInstance( ) ../Injector.php:297
12 0.1595 4329016 Horde_Core_Binder_Cache->create( ) ../Injector.php:261
13 0.1603 4362464 Horde_Core_Factory_Cache->getCache( ) ../Cache.php:11
14 0.1734 4603584 Horde_Core_Factory_Db->getDb( ) ../Cache.php:94
15 0.1735 4605000 Horde_Core_Factory_Db->getDb( ) ../Db.php:86
16 0.1735 4606280 Horde_Core_Factory_Db->_createDb( ) ../Db.php:91
17 0.1749 4633496 Horde_Injector->getInstance( ) ../Db.php:155
18 0.1749 4633496 Horde_Injector->createInstance( ) ../Injector.php:297
19 0.1750 4633544 Horde_Core_Binder_Cache->create( ) ../Injector.php:261
20 0.1750 4634056 Horde_Core_Factory_Cache->getCache( ) ../Cache.php:11
21 0.1750 4635968 Horde_Core_Factory_Db->getDb( ) ../Cache.php:94
22 0.1751 4637384 Horde_Core_Factory_Db->getDb( ) ../Db.php:86
23 0.1751 4638664 Horde_Core_Factory_Db->_createDb( )