I've run into a problem with that to. I'm using the Zend Application array
config and the array initializes the Session using the Zend DB Table. It
wont run unless in my bootstrap I initialize the db portion of the array
config. The function I used to fix it is below.

    /**
     * Simply initializes the database *before* the bootstrap tries to 
     * initialize the session using the db table handler.
     *
     * FIXME Why this is needed?
     */
    public function _initDatabase()
    {
                $this->bootstrapDb();
    }

-----Original Message-----
From: Vladimir Mihailenko [mailto:[email protected]] 
Sent: Tuesday, May 19, 2009 9:59 AM
To: [email protected]
Subject: Re: [fw-general] Zend_Application: setOptions() before bootstrap()


I think that it's bug - mb such explanation will be more clear:

Zend_Application::bootstrap()
    Zend_Application::setOptions()
        Zend_Application_Resource_Session::setOptions()
            Zend_Application_Resource_Session::setSaveHandler()
                Zend_Db_Table_Abstract::_setupDatabaseAdapter() throws
Zend_Db_Table_Exception
    only here starts resource bootstrapping, which have to initialize
database and session

See also:
http://www.nabble.com/Whats-wrong-with-my-bootstrap--td23586775.html


Matt Cockayne wrote:
> 
> I had the same problem. I got around it by createing a new save handler
> with an override of and setting the function to public so that it can be
> called by the resource
> 
> public function _setupDatabaseAdapter()
>     {
>         if (!$this->_db) {
>             $this->_db = self::getDefaultAdapter();
>             if (!$this->_db instanceof Zend_Db_Adapter_Abstract) {
>                 require_once 'Zend/Db/Table/Exception.php';
>                 // removed to prevent trowing of error as reloded in
> init()
>                 //throw new Zend_Db_Table_Exception('No adapter found for
> ' . get_class($this));
>             }
>         }
>     }
> 
> to exclude the exception from being thrown and then created a new session
> resource to force my db adapter to be bootstrapped and reload the default
> adapter
> 
> public function init()
>     {
>         // ensure view is initialized...
>         $this->getBootstrap()->bootstrap('Db');
>         if ($this->_saveHandler instanceof
> Zucchi_Session_SaveHandler_DbTable) {
>                       $this->_saveHandler->_setupDatabaseAdapter();
>         }
>         parent::init();
>     }
> 
> Thats it... problem solved. Something needs to be added to the Zend
> version of the resource/handler to ensure that the Db dependancy is
> satisfied.
> 
> 
> 
> Vladimir Mihailenko wrote:
>> 
>> When running my app after upgrade to 1.8.1 I got exception 'No adapter
>> found for Zend_Session_SaveHandler_DbTable'. During debugging I
>> discovered that before bootstrapping any resources Zend_Application sets
>> options via setOptions, which internally construct
>> Zend_Session_SaveHandler_DbTable. But in this moment there is no default
>> db adapter, because bootstrapping did not start -> no resources was
>> executed, but I have to Db resource to be executed. Am I the only who
>> meet this?
>> 
>> Fatal error:  Uncaught exception 'Zend_Db_Table_Exception' with message
>> 'No adapter found for Zend_Session_SaveHandler_DbTable' in
>> Z:\home\root\www\system\library\Zend\Db\Table\Abstract.php:667
>> 
>> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/Zend_Application%3A-setOptions%28%29-before-bootstrap%
28%29-tp23536214p23618144.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to