Skip to content
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

Cannot pass symfony/polyfill-intl-idn under PHP 7.4 #122

Open
wilbur-yu opened this issue Jan 11, 2021 · 4 comments
Open

Cannot pass symfony/polyfill-intl-idn under PHP 7.4 #122

wilbur-yu opened this issue Jan 11, 2021 · 4 comments

Comments

@wilbur-yu
Copy link

php version: 7.4.14

php artisan opcache:compile --force=true
PHP Parse error:  syntax error, unexpected '|', expecting '{' in /Users/wilbur.yu/MyCode/Work/qingyan/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php on line 18

Parse error: syntax error, unexpected '|', expecting '{' in /Users/wilbur.yu/MyCode/Work/qingyan/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php on line 18
[1]    86000 segmentation fault  php artisan opcache:compile --force=true
@lorenzocattaneo
Copy link

This seems to happen at

opcache_compile_file($file);

because polyfill files that require php 8 syntax are being parsed.

For now I've simply run php artisan vendor:publish --provider="Appstract\Opcache\OpcacheServiceProvider" --tag="config" to publish the config file and added the following to exclude:

'exclude' => [
        ...
        ...
        'symfony/polyfill-ctype',
        'symfony/polyfill-iconv',
        'symfony/polyfill-intl-grapheme',
        'symfony/polyfill-intl-idn',
        'symfony/polyfill-intl-normalizer',
        'symfony/polyfill-mbstring',
        'symfony/polyfill-php80'
    ],

Not a definitive solution but for now it works!

@jonathan-bird
Copy link

Any updates soon @ovanschie ? :)

@AEmad01
Copy link

AEmad01 commented Mar 25, 2021

The easy but not very viable solution is use php 8.

@stevegrunwell
Copy link
Contributor

I've spent some time digging into this today, and this appears to impact anyone running on PHP 7.x (7.4, in my case):

When iterating over the found files, opcache_compile_file() trips up on the bootstrap80.php files included within the various symfony/polyfill-* packages, as they use PHP 8.x-specific syntax (the polyfill packages themselves are a dependency of swiftmailer/swiftmailer, which is itself a dependency of laravel/framework).

Normally this wouldn't be a problem, as the Symfony packages only load these files when running on PHP 8.x. However, the list of files doesn't know about this, so we attempt to inject PHP 8.x syntax into a PHP 7.x OPcache and everything goes sideways.

The solution @lorenzocattaneo works as a short-term fix, but ultimately it's excluding everything in those symfony/polyfill-* packages from getting pre-loaded. @wojo1206's work in #125 would let us target specific files (as opposed to whole directories), which would be beneficial, but ultimately some better error handling within OpcacheClass::compile() is needed to prevent issues like this from breaking the whole process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants