Issues

ZF-7171: Zend_Session_SaveHandler_DbTable produces a fatal error

Description

When using Zend_Session_SaveHandler_DbTable, it's important to create a connection to the database after creating an instance of the adapter class. Otherwise, if there's a problem with the connection, you get a Fatal error: Exception thrown without a stack frame in Unknown on line 0, when catching the exception.


try {
    $db = Zend_Db::factory('Pdo_Mysql', $config->db);

    $adapter = new Zend_Session_SaveHandler_DbTable($config->session);
    Zend_Session::setSaveHandler($adapter); 
    Zend_Session::start();
} catch (Exception $e) {
    throw new Exception($e->getMessage());
}

/* Workaround: */
try {
    $db = Zend_Db::factory('Pdo_Mysql', $config->db);
    $db->getConnection();

    $adapter = new Zend_Session_SaveHandler_DbTable($config->session);
    Zend_Session::setSaveHandler($adapter); 
    Zend_Session::start();
} catch (Exception $e) {
    throw new Exception($e->getMessage());
}

http://fedecarg.codepad.org/5d2ckt3c

Comments

No comments to display