ZF-6651: Error within Zend_Session_SaveHandler

Issue Type: Bug Created: 2009-05-14T04:41:48.000+0000 Last Updated: 2009-09-18T09:05:14.000+0000 Status: Resolved Fix version(s): Reporter: Markus (rockaut) Assignee: Benjamin Eberlei (beberlei) Tags: - Zend_Session

Related issues: - ZF-6942

Attachments: - Session.patch


After i updated to 1.8.1 i got this error

Fatal error: Uncaught exception 'Zend_Db_Table_Exception' with message 'No adapter found for Zend_Session_SaveHandler_DbTable' in /is/htdocs/wp1133477_NBOOWRX8MH/libraries/Zend_1.8.1/Zend/Db/Table/Abstract.php:667 Stack trace:

0 /is/htdocs/wp1133477_NBOOWRX8MH/libraries/Zend_1.8.1/Zend/Db/Table/Abstract.php(652): Zend_Db_Table_Abstract->_setupDatabaseAdapter()

1 /is/htdocs/wp1133477_NBOOWRX8MH/libraries/Zend_1.8.1/Zend/Session/SaveHandler/DbTable.php(401): Zend_Db_Table_Abstract->_setup()

2 /is/htdocs/wp1133477_NBOOWRX8MH/libraries/Zend_1.8.1/Zend/Db/Table/Abstract.php(286): Zend_Session_SaveHandler_DbTable->_setup()

3 /is/htdocs/wp1133477_NBOOWRX8MH/libraries/Zend_1.8.1/Zend/Session/SaveHandler/DbTable.php(205): Zend_Db_Table_Abstract->__construct(Array)

4 /is/htdocs/wp1133477_NBOOWRX8MH/libraries/Zend_1.8.1/Zend/Application/Resource/Session.php(59): Zend_Session_SaveHandler_DbTable->__construct(Array)

5 /is/htdocs/wp1133477_NBOOWRX8MH/libraries/Zend_1.8.1/Zend/Application/Resource/ResourceAbstract.php(96): Zend_Ap in /is/htdocs/wp1133477_NBOOWRX8MH/libraries/Zend_1.8.1/Zend/Db/Table/Abstract.php on line 667

First i thought, i have defined resources.db in my .ini before resources.session, but it's not:

resources.db.isDefaultTableAdapter = true resources.db.adapter = "pdo_mysql" = "localhost" resources.db.params.driver_options.1002 = "SET NAMES utf8"

resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable" = "session" resources.session.saveHandler.options.primary = "id" resources.session.saveHandler.options.modifiedColumn = "modified" resources.session.saveHandler.options.dataColumn = "data" resources.session.saveHandler.options.lifetimeColumn = "lifetime"

I think, it's because while setOptions() in ResourceAbstract a new SaveHandler instance is created but at this point no DB Adapter is created because this should happen later in the init() calls!


Posted by old of Satoru Yoshida ( on 2009-05-14T17:08:38.000+0000

Set component and auto reassign

Posted by Markus (rockaut) on 2009-05-29T06:22:36.000+0000

Anyone on this Issue?

Posted by Piotr Minkina (likemandrake) on 2009-05-29T13:24:14.000+0000

My proposition to solve this problem (easy to implement). Please download Session.patch from attachment.

Posted by Markus (rockaut) on 2009-05-30T02:32:36.000+0000

Great! I will test it tonight and post the results.

Posted by Piotr Minkina (likemandrake) on 2009-05-30T15:14:22.000+0000

I tested my patch and I found some errors in my code... I'm sorry for this problem. Now, I fixed my code and upload file "Session.php" with "Zend_Application_Resource_Session" class. I think It should work very well. Test it, please!

PS: Sorry for my English

Posted by Markus (rockaut) on 2009-06-02T05:38:39.000+0000

Works -- with 1.8.2 as background now -- for me, thanks! If i run in other troubles with your code i will post it here.

Posted by Markus (rockaut) on 2009-07-02T23:55:34.000+0000

Ähm, 1.8.4 out and issue still exists :( But i copied the above file and it works like a charm, so please add it for next release!

Posted by Ten Ruslan (irt) on 2009-07-22T05:03:52.000+0000

Hi! Firstly sorry for my English)) I also have these problems. I think this is patch, is wrong solution.

My Solution

// application/bootstrap.php protected function _initDatabase() { $this->bootstrap('db'); $db = $this->getResource('db'); }

protected function _initSessionStart() { $this->bootstrap('session'); $session = $this->getPluginResource('session'); $session->init(); Zend_Session::start();


Config: // application/configs/application.ini resources.session.save_path = APPLICATION_PATH "/../data/session" = "Test" resources.session.use_only_cookies = true resources.session.remember_me_seconds = 1800

resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable" = "session"

resources.session.saveHandler.options.primary[] = "session_id" resources.session.saveHandler.options.primary[] = "save_path" resources.session.saveHandler.options.primary[] = "name"

resources.session.saveHandler.options.primaryAssignment[] = "sessionId" resources.session.saveHandler.options.primaryAssignment[] = "sessionSavePath" resources.session.saveHandler.options.primaryAssignment[] = "sessionName"

resources.session.saveHandler.options.modifiedColumn = "modified" resources.session.saveHandler.options.dataColumn = "session_data"

resources.session.saveHandler.options.lifetimeColumn = "lifetime"

Sorry for few words.

Posted by Piotr Minkina (likemandrake) on 2009-07-22T10:49:54.000+0000

Yes, Session.patch is bad solution, but I wrote about this above. Session.php is correct.

Posted by Ten Ruslan (irt) on 2009-07-23T02:47:41.000+0000

Your Session.php is correct and work, but i think this is not "Error within Zend_Session_SaveHandler", just we wrong use this resource. Thank you!

Posted by Ten Ruslan (irt) on 2009-07-23T02:52:20.000+0000

P.S And i think we no need modify Zend_Application_Resource_Session.

Posted by Piotr Minkina (likemandrake) on 2009-07-23T11:31:03.000+0000

I understand what you mean :) Thanks!

Best regards

Posted by Markus (rockaut) on 2009-07-29T03:26:25.000+0000

Hmm... using 1.9.0 RC1 and issue still present.

Session.php from above works with 1.9.0 RC1... so im using it for now... again.

Posted by Markus (rockaut) on 2009-08-01T08:31:46.000+0000

Updated to 1.9.0 issue present Session.php from above still working great

Sorry but i don't understand why you just can't include this patch for now. If there is a better way than just include it now and do the better work later. This issue could be solved as of 1.8.2 now.

Posted by Brian Morton ( on 2009-08-12T12:30:51.000+0000

It seems like the elegant solution here is to defer instantiation of the Zend_Session_SaveHandler_DbTable until Zend_Application_Resource_Session->init() since Zend_Application_Resource_Db->init() is where the adapter is created and set as default. The instructions are already clear to order the configuration options a certain way and the application plugin system maintains that order properly. All that is needed is to sync the creation of dependent/shared resources into the same method across plugins. In this case, they are out of sync with one being created in init and another being created in the setSaveHandler method.

I will attach a changed file outlining my concept. Perhaps someone can expand on it to make it meet code standards (which I am not familiar with).

Posted by Brian Morton ( on 2009-08-12T12:33:07.000+0000

Zend_Application_Resource_Session modifications to defer instantiation of savehandler until init()

Posted by Markus (rockaut) on 2009-09-02T23:58:23.000+0000

Ahem, once again:

Still not fixed in 1.9.2, while width above files it's working great.

Posted by Julien Breux (julienbreux) on 2009-09-12T16:28:20.000+0000

I think this correction is important because it will use only three lines for the bootstrap minimum ! The must !

Posted by Benjamin Eberlei (beberlei) on 2009-09-17T15:44:49.000+0000

This is a duplicate!

Posted by Piotr Minkina (likemandrake) on 2009-09-18T09:05:14.000+0000

No, ZF-6651 is not a duplicate, but ZF-6942 it is!

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.