[Tickets #9282] Re: Using SQL sessionhandler and SQL cache causes infinite recursion
bugs at horde.org
bugs at horde.org
Sun Jan 16 04:26:46 UTC 2011
DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.
Ticket URL: http://bugs.horde.org/ticket/9282
------------------------------------------------------------------------------
Ticket | 9282
Updated By | Chuck Hagenbuch <chuck at horde.org>
Summary | Using SQL sessionhandler and SQL cache causes infinite
| recursion
Queue | Horde Base
Version | Git master
Type | Bug
State | Assigned
Priority | 1. Low
Milestone | 4.0
Patch |
Owners | Horde Developers
------------------------------------------------------------------------------
Chuck Hagenbuch <chuck at horde.org> (2011-01-15 23:26) wrote:
Spent some time on this tonight and I'm leaning toward the problem
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.
More information about the bugs
mailing list