You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am updating a ZF1 app from PHP 5.3 ZF 1.12.20 to PHP 7.4.
I'm using zf1s 1.13.1 on PHP 7.4.8 with PHPUnit 7.5.20 and a Zend_Test_PHPUnit_ControllerTestCase and I'm getting the error
ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
I've taken a closer look. My application is in testing ENV and is testing itself. I have a TestHelper that bootstraps my application in "testing" ENV and a ControllerTestCase class that bootstraps another instance of the application in the setUp method for testing. Bootstraping the second instance fails with the error above.
Here is my setup for the TestHelper which is included for all tests:
The setUp() method in the ControllerTestCase class looks like this:
class ConfigurationTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp()
{
$this->bootstrap = new Zend_Application(
'testing',
APPLICATION_PATH . '/configs/application.ini'
);
$someSession = new Zend_Session_Namespace('someSession');
$someSession->data = ....
//more code here
parent::setUp(); // <-- this will bootstrap the test instance, error is here
}
Problem is this code in Zend_Session, starting at line 212:
// set the options the user has requested to set
foreach ($userOptions as $userOptionName => $userOptionValue) {
$userOptionName = strtolower($userOptionName);
// set the ini based values
if (array_key_exists($userOptionName, self::$_defaultOptions)) {
ini_set("session.$userOptionName", $userOptionValue); // <----- error is here
}
As the session was initiated correctly the first time and is up and running, this here is a possible solution:
I remember we also had this issue, but if I recall correctly, we simply ensured sessions are not used in tests.
There is Zend_Session::$_unitTestEnabled flag which is being set to true in our test suites (also zf test suite sets this flag to true internally), but this flag is not checked when Zend_Session::setOptions() is called - so we added a condition checks so that this method is not called.
But, we also do not use Zend_Test_PHPUnit_ControllerTestCase at all.. and that is probably calling that sessions options somewhere on the way (but is it really necessary? maybe the actual call to Zend_Session::setOptions() should be guarded?)
Anyway, since I do not have time resources at hand to test it on my own, I'd be glad if you could add a PR with a test for this issue. 🙏
I am updating a ZF1 app from PHP 5.3 ZF 1.12.20 to PHP 7.4.
I'm using zf1s 1.13.1 on PHP 7.4.8 with PHPUnit 7.5.20 and a Zend_Test_PHPUnit_ControllerTestCase and I'm getting the error
ini_set(): Headers already sent. You cannot change the session module's ini settings at this time
I've taken a closer look. My application is in testing ENV and is testing itself. I have a TestHelper that bootstraps my application in "testing" ENV and a ControllerTestCase class that bootstraps another instance of the application in the setUp method for testing. Bootstraping the second instance fails with the error above.
Here is my setup for the TestHelper which is included for all tests:
The setUp() method in the ControllerTestCase class looks like this:
Problem is this code in Zend_Session, starting at line 212:
As the session was initiated correctly the first time and is up and running, this here is a possible solution:
Shardj/zf1-future@82a4367#diff-dbc2d7706346875f0cbfb79798dfbfdd
What do you think?
The text was updated successfully, but these errors were encountered: