Hi!

With the change from ZF 1.0.2 to 1.0.3 I discovered a problem in interaction of 
Zend_Session::start() and Zend_Loader::isReadable() namely if isReadable() 
fails during session start.

Situation:

The app is organized in a conventional modular directory structure (as 
described in section 7.11 of the reference guide).

basedir
|-- application
|   |-- Module1
|   |   |-- controllers
|   |   |   |-- AuthController.php
|   |   |   `-- ...
|   |   |-- models
|   |   |   |-- Menu.php
|   |   |   `-- ...
|   |   `-- views
|   |       `-- scripts
...

To autoload the model classes I extended Zend_Loader (18.5) and wrote an own 
method which searches the proper directory for the file to include 
(Module1_Menu -> Module1/models/Menu.php).
Furthermore there is a custom Session_SaveHandler to have the session data 
managed in a DB. In the read() method of the SaveHandler I use a model class 
(Module1_Session) to get the session data from.

Now the following happens:
In the bootstrapper I setup the autoloader:
Zend_Loader::registerAutoload('Custom_Loader');

Zend_Session::setSaveHandler(new Custom_Session_SaveHandler());
Zend_Session::start();

I end up with:
Zend_Session_Exception: Zend_Session::start() - fopen(Module1/Session.php) 
[function.fopen]: failed to open stream: No such file or directory in 
ZendFramework-1.0.3/library/Zend/Session.php on line 380

That's the situation... now my analysis
In Zend_Session (line 372) a new error handler is set and than session_start() 
is called. This calls read() method of Custom_Session_SaveHandler which tries 
to load Module1_Session to get the session data (new Module1_Session();). While 
trying to load Module1_Session Zend_Loader::isReadable gets called like this: 
self::isReadable('Module1/Session.php') which fails and now in the 1.0.3 code 
because of the new fopen approach (Zend_Loader 194) error level E_WARNING is 
generated. This is handled by Zend_Session_Exception::handleSessionStartError() 
which later leads to the Exception from above.

I read the mails regarding the performance issues of Zend_Loader::isReadable so 
maybe it could be a solution to tweak Zend_Session_Exeption to ignore such 
fopen warnings. Or set_error_handler for E_ERROR only. Because as I understand 
it the code parts there exist to circumvent: 
http://framework.zend.com/issues/browse/ZF-1325

At the moment I require Module1/models/Session.php manually, which is is not 
very smart with an autoloader available.

Any hints, comments, etc. welcome

Regards
-joachim knust






Reply via email to