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

Support PHP 8 #1325

Merged
merged 8 commits into from
Dec 30, 2020
Merged

Support PHP 8 #1325

merged 8 commits into from
Dec 30, 2020

Conversation

nicwortel
Copy link
Contributor

@nicwortel nicwortel commented Dec 24, 2020

Q A
Branch? 2.0
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #1309
License MIT
Doc PR not needed

Alternative to #1313. This PR adds the 8.0 builds to GitHub Actions instead of Travis CI.
Feel free to close this PR in favor of #1313 and/or use my work in that PR.

Happy holidays! 🎄

@coveralls
Copy link

coveralls commented Dec 24, 2020

Coverage Status

Coverage decreased (-0.04%) to 81.371% when pulling 6f85d96 on nicwortel:php8 into c06594a on liip:master.

In PHP8 vsprintf throws a ValueError when called with not enough arguments.
Older versions of imagine/imagine had incompatibilities with PHP 8, even though their composer.json stated it supported PHP 8.
"php": "^7.1",
"imagine/imagine": "^1.1",
"php": "^7.1|^8.0",
"imagine/imagine": "^1.2.4",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in the commit message:

Older versions of imagine/imagine had incompatibilities with PHP 8, even though their composer.json stated it supported PHP 8.

See php-imagine/Imagine@e68b92b.

if (false !== $compiled = @vsprintf($format, $replacements)) {
return $compiled;
}
} catch (ValueError $error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to catch the error instead of changing the tests, to keep the contract consistent across PHP versions.

@nicwortel nicwortel marked this pull request as ready for review December 24, 2020 19:11
@nicwortel
Copy link
Contributor Author

The tests are passing on CI.

On my local machine I'm getting a number of Symfony\Component\DependencyInjection\Exception\ServiceNotFoundExceptions in the ImagineControllerTest, which appear to be caused by a private service liip_imagine.service.filter being fetched from the container in a conditional branch of the test which only runs when the function imagewebp exists.

I can see that imagewebp is being disabled on GitHub Actions and I'm assuming it's also not available on Travis CI? This leads me to believe that this branch of the test doesn't really work and hasn't been tested for a while.

I decided not to touch this in this PR because using self::$container instead of self::$kernel->getContainer() in the test will probably break the Symfony 3.4 job and it's out of scope for this PR. Besides, there seem to be some additional problems as well so I rather not go down the rabbit hole right now. If you want me to, I can see if I can fix this in a separate PR.

@lsmith77
Copy link
Contributor

@nicwortel
Copy link
Contributor Author

@lsmith77

this PR overlaps with #1313

That's correct! I noticed that the build of #1313 was failing and I wanted to take a shot to fix it, as I needed LiipImagineBundle in a new PHP 8 project (I'm currently using my fork as a Composer dependency).
Also, after the creation of #1313 this repository was migrated from Travis CI to GitHub Actions, so this PR adds the build to GH Actions instead of Travis CI.

It isn't my intention to steal @garak's thunder so feel free to close this PR in favor of #1313 and/or reuse my work there 🙂

also note the discussion here https://github.com/liip/LiipImagineBundle/pull/1313/files#diff-6ac3f79fc25d95cd1e3d51da53a4b21b939437392578a35ae8cd6d5366ca5485R39

Yes, I ran into the same issue working on this PR. I fixed it by raising the required imagine/imagine version to ^1.2.4 which fixes a PHP 8 incompatibility (also see this comment), to prevent people running an incompatible version on PHP 8. Let me know if you'd prefer me to roll that back and instead run the --prefer-lowest job on an older PHP version (such as 7.4).

@lsmith77
Copy link
Contributor

ok. sounds good.

will wait for @fbourigault to give a nod befire merging

@lsmith77 lsmith77 mentioned this pull request Dec 30, 2020
Copy link
Contributor

@fbourigault fbourigault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@garak
Copy link
Contributor

garak commented Dec 30, 2020

It isn't my intention to steal @garak's thunder so feel free to close this PR in favor of #1313 and/or reuse my work there slightly_smiling_face

Thanks for worrying about it, no problem on my side

@lsmith77 lsmith77 merged commit d5ae27d into liip:master Dec 30, 2020
@nicwortel nicwortel deleted the php8 branch January 17, 2021 13:31
@stephanvierkant
Copy link

When will a new version be released?

@stephanvierkant
Copy link

Ping @lsmith77

@lsmith77
Copy link
Contributor

lsmith77 commented Feb 9, 2021

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

Successfully merging this pull request may close these issues.

6 participants