Hi, I was wondering when PHP 7.2 will be officially supported by Cake. I have the latest Cake version (3.5.9) and tried it with PHP 7.2.0 yesterday. The site seems to work fine (after I changed some config/app.php settings), but during unit testing (with PHPUnit 6.5.5) I’m seeing a ton of new PHP warnings. The only change I made was upgrading from PHP 7.1.12 to 7.2.0.
The warnings are new in 7.2 - I even saw them in PHP’s source code. They changed the way sessions are handled. Cake has some sessions code to help with this change but it doesn’t seem sufficient yet. Some people are calling the new warnings a PHP bug. So I was just wondering if the Cake team had plans or a timeline to address this. I want to use the new security features in 7.2 but I’d prefer to wait until all the warnings/notices disappear.
Here’s an example of the warnings:
session_set_save_handler(): Cannot change save handler when headers already sent
The warnings mostly occur during unit testing when a route is accessed. Technically, the warning is correct since PHPUnit has already output to the console when the route is accessed and the session is attempting to re-initialize.
The change I had to make to my app.php file was for the Sessions config. I had to copy all of the database defaults but leave the “session.save_handler” entry missing so that Cake wouldn’t try to set it to “user”, which is now an invalid option.
Thanks for the advice guys. I looked into your suggestions, and the problem persists. The good news is that this problem is repeatable. I installed a fresh copy of Cake and got the warnings by changing the Session config to use database sessions.
Steps to reproduce:
Install a new copy of CakePHP
Edit the Session section of config/app.php to include this from the docs:
You will hopefully see the same PHP warnings that I do:
Warning (2): session_set_save_handler(): Cannot change save handler when headers already sent in […/my_app_name/vendor/cakephp/cakephp/src/Network/Session.php, line 220]
I don’t see those warnings if I use the “php” Session defaults, so something about the database sessions seems to make the difference.
Adding ‘defaults’ => ‘database’ to the config doesn’t make any difference.
On a related note, digging into the Cake source in Session.php, it looks like database sessions set ‘session.save_handler’ => ‘user’, which is no longer a valid PHP session setting.
I also get the following error with php 7.2.7 from cakephp 3.6.7 with phpunit 7.2.6 on mac os Sierra 10.13.3. Anybody get this error as well on mac ? (I have no errors with php 7.x, on mac and windows with cake 3.5.x and 3.6.x but phpunit 6.2.4)
And according to this post, BaseTestListener has been removed in phpunit 7.
PHP Fatal error: Class 'PHPUnit\Framework\BaseTestListener' not found in /Users/zzz/Sites/yyy/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php on line 28
Fatal error: Class 'PHPUnit\Framework\BaseTestListener' not found in /Users/xxx/Sites/eva/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php on line 28
Fatal Error: Class 'PHPUnit\Framework\BaseTestListener' not found in [/Users/zzz/Sites/yyy/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php, line 28]
I have the same problem with CakePHP 3.4.14 through 3.7.0 on PHP 7.2.13 on Debian stretch (PHP 7.2.13 installed from sury repo.)
I want to store sessions on Redis, my app.config is as follows: 'Session' => [ //'defaults' => 'php', 'handler' => [ 'config' => 'session' ], 'defaults' => 'cache', 'ini' => [ // Invalidate the cookie after 30 minutes without visiting // any page on the site. 'session.cookie_lifetime' => 1209600 ], 'timeout' => 20160 ],
the issue goes away by commenting the following line in Session.php file but it’s not the right solution: 'cache' => [ 'cookie' => 'CAKEPHP', 'ini' => [ 'session.use_trans_sid' => 0, 'session.use_cookies' => 1, #'session.save_handler' => 'user', ], 'handler' => [ 'engine' => 'CacheSession', 'config' => 'default' ] ],
Anyone has any answers whether an update can solve this or I should downgrade to PHP7.1