Issue Type: Bug Created: 2009-06-10T02:08:02.000+0000 Last Updated: 2009-08-19T08:02:16.000+0000 Status: Resolved Fix version(s): Reporter: Jason Brumwell (baxter) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Application
Related issues: - ZF-6942
I'm trying to use Zend_Applicatoin to load my database then Session. Here is the snippet of the ini file:
phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0
autoloadernamespaces.nexus = "NEXUS_" autoloadernamespaces.nexus = "APPLICATION_"
includePaths.library = LIBRARY_PATH includePaths.application = APPLICATION_PATH
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap"
resources.db.adapter = "PDO_MYSQL" resources.db.params.host = "localhost" resources.db.params.username = "root" resources.db.params.password = "" resources.db.params.charset = "utf8" resources.db.params.dbname = "tbr" resources.db.isDefaultTableAdapter = true
resources.modules = true
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.frontController.actionhelperpaths.main = APPLICATION_PATH "/controllers/helpers" ;resources.frontController.baseUrl = "/subdir" ;resources.frontController.plugins.foo = "My_Plugin_Foo" ;resources.frontController.plugins.bar = "My_Plugin_Bar" resources.frontController.env = APPLICATION_ENV
resources.session.save_path = DATA_PATH "/session" resources.session.use_only_cookies = true resources.session.remember_me_seconds = 864000 resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable" resources.session.saveHandler.options.name = "session" resources.session.saveHandler.options.primary.session_id = "session_id" resources.session.saveHandler.options.primary.save_path = "save_path" resources.session.saveHandler.options.primary.name = "name" resources.session.saveHandler.options.primaryAssignment.sessionId = "sessionId" resources.session.saveHandler.options.primaryAssignment.sessionSavePath = "sessionSavePath" resources.session.saveHandler.options.primaryAssignment.sessionName = "sessionName" resources.session.saveHandler.options.modifiedColumn = "modified" resources.session.saveHandler.options.dataColumn = "session_data" resources.session.saveHandler.options.lifetimeColumn = "lifetime"
What happends is when Zend_Application_Resource_Session is loaded via BootstrapAbstract.php _loadPluginResource it is passed to Zend_Application_Resource_ResourceAbstract which passes to its setOptions method which calls Zend_Application_Resource_Session::setSavehandler which loads the table abstract and dies at no adapter because the db resource init function has yet to be run and thus not connected and default adapter not set.
Hope it makes sence Its pretty late here and quite tired. If I'm missing something please point me in the right direction as google didn't solve this issue.
All the best,
Posted by julien PAULI (doctorrock83) on 2009-06-16T04:27:37.000+0000
This duplicates #ZF-6942
Posted by Jason Brumwell (baxter) on 2009-06-16T05:32:49.000+0000
I'm not sure if this is the same, as I was aware of the dependancy on the db resource and did as the documentation stated:
Bootstrap your database first!
If you are configuring the Zend_Session_SaveHandler_DbTable session save handler, you must first configure your database connection for it to work. Do this by either using the Db resource -- and make sure the "resources.db" key comes prior to the "resources.session" key -- or by writing your own resource that initializes the database, and specifically sets the default Zend_Db_Table adapter.
The bug you linked states:
Using Resource_Session with the DbTable-Savehandler cause an exception, if the Db-Resource is not called before.
but I was unable to get it to work without moving it to the bootstrap _iniDb and initializing the database. I just wanted to ensure that the correct bug is put forward.
Posted by Adam Weinstock (adamweinstock) on 2009-07-14T00:44:20.000+0000
I'm getting this too.
The problem occurs because Zend_Application_Bootstrap_BootstrapAbstract::getPluginResourceNames() calls Zend_Application_Bootstrap_BootstrapAbstract::getPluginResources() which in turn calls Zend_Application_Bootstrap_BootstrapAbstract::_loadPluginResource(). This instantiates but does not execute instances of the registered resource objects, causing Zend_Application_Resource_Session::setSaveHandler() to instantiate an instance of Zend_Db_Table_Abstract before the Db resource is actually executed. Since Zend_Application_Resource_Db doesn't call Zend_Db_Table::setDefaultAdapter() until it's init() method is called, the desired behavior fails.
The simplest solution seems to be to remove the call to getPluginResources() in Zend_Application_Bootstrap_BootstrapAbstract::getPluginResourceNames(). This seems to be working for me, but may cause problems, so another solution may be more desirable. In any case, this bug will definitely cause problems with other resources down the line and should be fixed up.
Posted by Kevin Foster (kevinfoster) on 2009-08-19T08:02:16.000+0000
I have the same problem after upgrading from 1.7.8 to 1.9.1. It seems this bug has been recently introduced.
Have you found an issue?
See the Overview section for more details.