-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix support for PHP 7.2 #23711
Fix support for PHP 7.2 #23711
Conversation
57d52ed
to
e041175
Compare
.travis.yml
Outdated
@@ -31,6 +31,8 @@ matrix: | |||
env: deps=high | |||
- php: 7.1 | |||
env: deps=low | |||
- php: 7.2 | |||
env: deps=high |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to add a new section, 7.1 should be changed to 7.2 just above instead, deps=low
9c44ac7
to
28ae236
Compare
@nicolas-grekas Could you give me insight on how to fix this ? I need to look for the seg fault too. |
28ae236
to
fe1e9f2
Compare
Dunno sorry... |
fe1e9f2
to
5dfd95a
Compare
$storage->write('gc_id', 'data'); | ||
$storage->close(); | ||
$this->assertEquals(2, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn(), 'No session pruned because gc not called'); | ||
// @TODO: Really not sure about this at all.... | ||
true === headers_sent() && $storage->destroy('gc_id'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess @stof or @ogizanagi could know if there is something better then this dirty hack ?
5dfd95a
to
05017ef
Compare
@@ -348,7 +352,7 @@ public function setOptions(array $options) | |||
)); | |||
|
|||
foreach ($options as $key => $value) { | |||
if (isset($validOptions[$key])) { | |||
if (isset($validOptions[$key]) && false === headers_sent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo you should test for (PHP_VERSION_ID < 70200 || false=== headers_sent())
, in order to keep the original (even flawed) behavior...
But that may be dirty actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's actually a little dirty. Then we should do that in every modified component
d3d321a
to
49302f5
Compare
.github/build-packages.php
Outdated
$packages = array(); | ||
$flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert this. These lines were here for readability
.travis.yml
Outdated
@@ -141,7 +141,7 @@ install: | |||
export SYMFONY_DEPRECATIONS_HELPER=weak && | |||
cp composer.json composer.json.orig && | |||
echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json && | |||
php .github/build-packages.php HEAD^ $COMPONENTS && | |||
(php .github/build-packages.php HEAD^ $COMPONENTS || true) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ? If this fails, the build will be garbage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it does trigger a fatal on git and because of that trigger a fatal on php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have a better way for this, maybe by fixing github/build-packager.php:11
$mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs))));
that triggers a git fatal then a seg fault than a exit 139
which lead to a build failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to have the test running and we should be discussing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/home/travis/.travis/job_stages: line 57: 14926 Segmentation fault (core dumped) $COMPOSER_UP
The command "if [[ ! $skip ]]; then $COMPOSER_UP; fi" failed and exited with 139 during .
ini_set('session.save_handler', 'files'); | ||
ini_set('session.save_path', sys_get_temp_dir()); | ||
//ini_set('session.save_handler', 'files'); | ||
//ini_set('session.save_path', sys_get_temp_dir()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code should not be commented. If it is not needed anymore, it should be removed
@@ -348,7 +352,7 @@ public function setOptions(array $options) | |||
)); | |||
|
|||
foreach ($options as $key => $value) { | |||
if (isset($validOptions[$key])) { | |||
if (isset($validOptions[$key]) && false === headers_sent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be checked for each option, but only once before the loop.
And it should use !header_sent()
@@ -282,18 +282,20 @@ public function testSessionGC() | |||
|
|||
$storage->open('', 'sid'); | |||
$storage->read('gc_id'); | |||
ini_set('session.gc_maxlifetime', -1); // test that you can set lifetime of a session after it has been read | |||
// IN 7.2 this does not work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this test does not work in PPH 7.2, this case should be extracted to a separate test and be skipped when unapplicable instead of skipping one step (and ensuring other things still work)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
.travis.yml
Outdated
# - php: 5.3 | ||
# - php: 5.4 | ||
#- php: 5.5 | ||
#- php: 5.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must be reverted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be reverted
.travis.yml
Outdated
- php: 7.0 | ||
env: deps=high |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must be reverted
.travis.yml
Outdated
- php: 7.0 | ||
env: deps=high | ||
- php: 7.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to keep a PHP 7.1 job (even though it is not one doing a special handling of deps). Otherwise, Symfony would be untested on 7.1, which is not acceptable.
@@ -35,4 +35,4 @@ | |||
"dev-master": "2.7-dev" | |||
} | |||
} | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must be reverted
@@ -38,7 +38,7 @@ public function testDefaultLocaleWithoutSession() | |||
public function testLocaleFromRequestAttribute() | |||
{ | |||
$request = Request::create('/'); | |||
session_name('foo'); | |||
// session_name('foo'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commenting is a no-go. If we don't want this code anymore, it should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that, I think it's like you said, all of this should be skipped on 7.2
Thanks @stof for the review ill do the changes |
eaa77c6
to
5d4838b
Compare
Ok, I couldn't add || true on the phpunit running that would be wrong. But everything is triggering a segfault. @remicollet maybe you have an idea ? |
5d4838b
to
e16c012
Compare
@Simperfit please avoid mentioning me in your commit message when fixing the review. This sends me a notification when pushing the commit to Github. And anytime you amend or rebase the commit, this creates a new commit, and so pushing it sends me another notification. |
.travis.yml
Outdated
- if [[ ! $skip ]]; then $COMPOSER_UP; fi | ||
- if [[ ! $skip ]]; then ./phpunit install; fi | ||
- if [[ ! $skip ]]; then $COMPOSER_UP || true; fi | ||
- if [[ ! $skip ]]; then ./phpunit install || true; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding || true
is totally a no-go. If the setup of the testsuite fails, we don't want to ignore the failure and try the next step. This would just lead to an output impossible to understand due to weird failures later (trying to use the packages which were not installed properly before)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know how we could debug this segmentation fault ? I think something needs to be done globally in the script since it does not work even adding OR true
.travis.yml
Outdated
- | | ||
# phpinfo | ||
if [[ ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi | ||
if [[ ! $PHP = hhvm* ]]; then php -i || true; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does php -i
really fail ? If yes, it means that the PHP shipped in Travis is totally broken, and there is no hope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does not fail since it shows the phpinfo();
but it seems that it triggers a segfault
@@ -25,8 +25,10 @@ class LegacyDefaultCsrfProviderTest extends TestCase | |||
|
|||
public static function setUpBeforeClass() | |||
{ | |||
ini_set('session.save_handler', 'files'); | |||
ini_set('session.save_path', sys_get_temp_dir()); | |||
if (PHP_VERSION_ID < 70200) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP_VERSION_ID
should be fully-qualified instead of relying on constant fallback, to allow resolving the version check at compilation time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean ? (PHP_VERSION
maybe ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, understood
@@ -271,6 +271,10 @@ public function testSessionDestroy() | |||
|
|||
public function testSessionGC() | |||
{ | |||
if (PHP_VERSION_ID === 70200) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would make the test run again on 7.2.1. Are you sure about it ?
ini_set('session.save_handler', 'files'); | ||
ini_set('session.save_path', sys_get_temp_dir()); | ||
//ini_set('session.save_handler', 'files'); | ||
//ini_set('session.save_path', sys_get_temp_dir()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commenting code is still a no-go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove
e16c012
to
40a1c7d
Compare
5f48ccd
to
25f9519
Compare
25f9519
to
b0e92fc
Compare
…ethod (nicolas-grekas) This PR was merged into the 3.3 branch. Discussion ---------- [Bridge\PhpUnit] Fix infinite loop when running isolated method | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - May unlock #23003 (ping @paul-m) And required to make #23711 pass. Commits ------- e07c2f1 [Bridge\PhpUnit] Fix infinite loop when running isolated method
cf43c55
to
306cd02
Compare
306cd02
to
fdf285b
Compare
Tests are now green and PR is ready. |
thanks for the help ! |
Thank you @Simperfit. |
This PR was merged into the 2.7 branch. Discussion ---------- Fix support for PHP 7.2 | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | #23671 | License | MIT | Doc PR | - There are still the deprecation problem with phpunit since it use `each()`. There are 3 tests linked to session that I don't know how to fix / what to do, do you have any idea @nicolas-grekas ? Commits ------- fdf285b Fix 7.2 compat layer e229dd0 Fix PHP 7.2 support
@@ -383,6 +394,10 @@ public function setSaveHandler($saveHandler = null) | |||
throw new \InvalidArgumentException('Must be instance of AbstractProxy or NativeSessionHandler; implement \SessionHandlerInterface; or be null.'); | |||
} | |||
|
|||
if (headers_sent($file, $line)) { | |||
throw new \RuntimeException(sprintf('Failed to set the session handler because headers have already been sent by "%s" at line %d.', $file, $line)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Simperfit @nicolas-grekas why do we throw in here while we return
in the other cases? This definitely smells BC break 🤔
There are still the deprecation problem with phpunit since it use
each()
.There are 3 tests linked to session that I don't know how to fix / what to do, do you have any idea @nicolas-grekas ?