Closed xurizaemon closed 2 years ago
@xurizaemon , Does it break driver tests on PHP 8.1 as well?
@stof , Do we actually test Mink on PHP 8.1?
@aik099 this only triggers a deprecation warning, not a error. And so it will not break the testsuite on PHP 8.1 (it would break it for PHP 9.0). We do test Mink and the drivers on PHP 8.1. But this code is not executed as part of the testsuite (where we do report deprecations) but as part of the test server serving fixtures (where we don't report deprecations back to the testsuite)
@aik099 it does for DMore/chrome-mink-driver - fail on 8.1, pass on 8.0 and earlier PHP versions via a WIP issue there to bring PHP support up to date. Since that driver's tests run with E_ALL
the deprecation notice shows up in output and prevents the cookie working.
This change to swap null
for 0
proposed here will make it consistent with the other setcookie()
usages in this codebase (1 2 3). This null is a straggler IMO :)
To reproduce the deprecation notice in CLI:
$ docker run -ti php:8.1 php -a
Interactive shell
php > setcookie('foo', 'bar', null, '/');
Deprecated: setcookie(): Passing null to parameter #3 ($expires_or_options) of type array|int is deprecated in php shell code on line 1
It doesn't look like https://github.com/minkphp/driver-testsuite/blob/master/bin/mink-test-server sets error_reporting, so whether this notice will break cookie functionality on other drivers using this will depend on the error_reporting configuration that mink-test-server (etc) is run with (until 9.0 as @stof notes).
However, I see that MinkGoutteDriver sets error_reporting(-1)
in "Setup PHP" and then does not fail eg here, which I'd expect to reveal the same behaviour. (I'm not familiar with that driver's tests yet!)
Verified that this does fail the MinkGoutteDriver test suite when run locally.
See updated issue description for steps to reproduce using that driver.
Hi! This PR addresses a PHP8 deprecation / PHP9 fatal error in test suite fixtures.
It was approved in late January. Issue description contains steps to reproduce and reference to PHP core details.
This error will break tests on PHP9. Until then it can be masked by error_reporting(-1)
but I believe we should be proactive and fix it sooner not later.
What more can I do to assist in having this small correction merged?
Merging, thanks @xurizaemon .
See https://www.php.net/manual/en/function.setcookie.php - passing a boolean here as the third of >3 parameters triggers warning in output on PHP8.1 (which prevents cookie getting set and breaks cookie tests for me).
It's also valid post 7.3 to pass an array as the third parameter. From 8.1 passing other types (eg
null
in this instance) emits a deprecation notice, and this usage will fail from 9.0.Steps to reproduce
To reproduce using minkphp/MinkGoutteDriver and PHP8.1
git clone git@github.com:minkphp/MinkGoutteDriver
cd MinkGoutteDriver
docker run --rm -ti -v $(pwd):/code composer bash
(currently this is PHP8.1)./vendor/bin/mink-test-server
(I used a separatedocker exec... bash
on the same container to do this)./vendor/bin/phpunit
(output below)curl -s http://localhost:8002/sub-folder/cookie_page4.php | grep -E '(Deprecated|Warning)'
to see why the test failed