Zend Framework

Error within Zend_Session_SaveHandler

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Blocker Blocker
  • Resolution: Duplicate
  • Affects Version/s: 1.9.0
  • Fix Version/s: None
  • Component/s: Zend_Session
  • Labels:
    None

Description

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"
resources.db.params.host = "localhost"
resources.db.params.driver_options.1002 = "SET NAMES utf8"

resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.name = "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!

  1. Session.patch
    29/May/09 1:24 PM
    2 kB
    Piotr Minkina
  2. Session.php
    12/Aug/09 12:32 PM
    3 kB
    Brian Morton
  3. Session.php
    30/May/09 3:14 PM
    3 kB
    Piotr Minkina

Issue Links

Activity

Hide
Satoru Yoshida added a comment -

Set component and auto reassign

Show
Satoru Yoshida added a comment - Set component and auto reassign
Hide
Markus added a comment -

Anyone on this Issue?

Show
Markus added a comment - Anyone on this Issue?
Hide
Piotr Minkina added a comment -

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

Show
Piotr Minkina added a comment - My proposition to solve this problem (easy to implement). Please download Session.patch from attachment.
Hide
Markus added a comment -

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

Show
Markus added a comment - Great! I will test it tonight and post the results.
Hide
Piotr Minkina added a comment -

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

Show
Piotr Minkina added a comment - 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
Hide
Markus added a comment -

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.

Show
Markus added a comment - 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.
Hide
Markus added a comment -

Ä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!

Show
Markus added a comment - Ä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!
Hide
Ten Ruslan added a comment -

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"
resources.session.name = "Test"
resources.session.use_only_cookies = true
resources.session.remember_me_seconds = 1800

resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.name = "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.

Show
Ten Ruslan added a comment - 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" resources.session.name = "Test" resources.session.use_only_cookies = true resources.session.remember_me_seconds = 1800 resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable" resources.session.saveHandler.options.name = "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.
Hide
Piotr Minkina added a comment -

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

Show
Piotr Minkina added a comment - Yes, Session.patch is bad solution, but I wrote about this above. Session.php is correct.
Hide
Ten Ruslan added a comment -

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!

Show
Ten Ruslan added a comment - 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!
Hide
Ten Ruslan added a comment -

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

Show
Ten Ruslan added a comment - P.S And i think we no need modify Zend_Application_Resource_Session.
Hide
Piotr Minkina added a comment -

I understand what you mean Thanks!

Best regards

Show
Piotr Minkina added a comment - I understand what you mean Thanks! Best regards
Hide
Markus added a comment -

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.

Show
Markus added a comment - 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.
Hide
Markus added a comment -

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.

Show
Markus added a comment - 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.
Hide
Brian Morton added a comment -

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).

Show
Brian Morton added a comment - 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).
Hide
Brian Morton added a comment -

Zend_Application_Resource_Session modifications to defer instantiation of savehandler until init()

Show
Brian Morton added a comment - Zend_Application_Resource_Session modifications to defer instantiation of savehandler until init()
Hide
Markus added a comment -

Ahem, once again:

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

Show
Markus added a comment - Ahem, once again: Still not fixed in 1.9.2, while width above files it's working great.
Hide
Julien Breux added a comment -

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

Show
Julien Breux added a comment - I think this correction is important because it will use only three lines for the bootstrap minimum ! The must !
Hide
Benjamin Eberlei added a comment -

This is a duplicate!

Show
Benjamin Eberlei added a comment - This is a duplicate!
Hide
Piotr Minkina added a comment -

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

Show
Piotr Minkina added a comment - No, ZF-6651 is not a duplicate, but ZF-6942 it is!

People

Vote (5)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: