ZF-7288: Zend_Session::start overwrites error handler to test if session start failed
Description
I think it is better to check this by using error_get_last (http://de.php.net/manual/en/…) and since PHP 5.3 you can simply check the return value of session_start.
This could be the new session_start check
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
$errBefore = error_get_last();
@session_start();
$errAfter = error_get_last();
if ($errBefore != $errAfter) {
throw new Zend_Session_Exception('Failed to start session: ' . $errAfter['message']);
}
} else {
if (@session_start() === false) {
$errLast = error_get_last();
throw new Zend_Session_Exception('Failed to start session: ' . $errLast['message']);
}
}
Comments
Posted by Marc Bennewitz (private) (mabe) on 2009-07-15T12:58:44.000+0000
ZF-7288 would fix ZF-7217, too
Posted by Goran Juric (gog) on 2009-11-12T14:54:48.000+0000
As much as I can see from the PHP docs, there is no need for error suppression in the else block.
session_start() returns either true or false in PHP 5.3
I guess this is not the only thing that should change with 5.3 becoming more and more popular. I think there should be a single place where we could document issues like this one, so once the 5.3 becomes a requirement for running ZF we can get rid of the BC code.
Posted by Adam Lundrigan (adamlundrigan) on 2012-05-31T14:25:46.000+0000
But it restores the error handler right after:
So I don't see what the issue is. Could someone provide an example of why this behavior is bad/wrong?