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

PHP 8.0 Deprecation Warning #2580

Closed
timnolte opened this issue May 25, 2022 · 21 comments
Closed

PHP 8.0 Deprecation Warning #2580

timnolte opened this issue May 25, 2022 · 21 comments

Comments

@timnolte
Copy link

Expected behavior

Classes updated in order to be compatible with future versions of PHP and not fill up logs with Deprecation warnings.

Actual behavior

[25-May-2022 20:25:42 UTC] PHP Deprecated:  Required parameter $lineno follows optional parameter $only in /var/www/html/public/wp-content/plugins/timber-library/vendor/twig/twig/src/Node/EmbedNode.php on line 26
[25-May-2022 20:25:42 UTC] PHP Deprecated:  Required parameter $lineno follows optional parameter $only in /var/www/html/public/wp-content/plugins/timber-library/vendor/twig/twig/src/Node/IncludeNode.php on line 25

Steps to reproduce behavior

Update a site to run under PHP 8.0.

What version of WordPress, PHP and Timber are you using?

WordPress 5.9.3, PHP 8.0.16, Timber 1.19.1

How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)

Composer via wpackagist.org

@okadots
Copy link

okadots commented May 31, 2022

I am also seeing this deprecation notice. Shows up when I try to {{ dump(someVariable)}}
Deprecated: Method ReflectionParameter::isArray() is deprecated in /var/www/wp-content/plugins/timber-library/vendor/twig/twig/src/Node/Expression/CallExpression.php on line 257

WP 5.9.3, php 8.0, Timber plugin 1.19.1

@G-Rath
Copy link

G-Rath commented Jun 15, 2022

It looks like these are fixed in the latest versions of Twig (across all majors), so this should be fixed when a new version is release (as I assume that gets packed with whatever the latest version of Twig is at the time) - hopefully that'll be soon 🤞

@timnolte
Copy link
Author

I was hopeful when I saw that 1.20.0 was out that these would be resolve but it doesn't look like it. :-/

@IonTulbure
Copy link

IonTulbure commented Jul 5, 2022

I am getting lots of deprecated warnings :

Deprecated: Return type of Timber\QueryIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/kinsta/public/udemywtdwtat/wp-content/plugins/timber-library/lib/QueryIterator.php on line 137

Deprecated: Return type of Timber\QueryIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/kinsta/public/udemywtdwtat/wp-content/plugins/timber-library/lib/QueryIterator.php on line 150

Deprecated: Return type of Timber\QueryIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/kinsta/public/udemywtdwtat/wp-content/plugins/timber-library/lib/QueryIterator.php on line 156

Deprecated: Return type of Timber\QueryIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/kinsta/public/udemywtdwtat/wp-content/plugins/timber-library/lib/QueryIterator.php on line 133

Deprecated: Return type of Timber\QueryIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/kinsta/public/udemywtdwtat/wp-content/plugins/timber-library/lib/QueryIterator.php on line 152

Deprecated: Return type of Timber\QueryIterator::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/kinsta/public/udemywtdwtat/wp-content/plugins/timber-library/lib/QueryIterator.php on line 202

Deprecated: Return type of Timber\PostsIterator::current() should either be compatible with ArrayIterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/kinsta/public/udemywtdwtat/wp-content/themes/timber-start/vendor/timber/timber/lib/PostsIterator.php on line 12

@G-Rath
Copy link

G-Rath commented Jul 5, 2022

Yeah looks like the vendored version of Twig wasn't updated - it's using 1.42.5 whereas the latest (which has the PHP 8 & 8.1 compat fixes) is 1.44.6 (for PHP 8 we only need to be on 1.43.0 I think).

@jarednova would it be possible to get a new version of the WordPress plugin released that has an updated version of Twig?

@timnolte
Copy link
Author

Is there and ETA on this. The days are number before PHP 7.4 is EOL and we are trying to get all of our client sites updated to PHP 8. Fortunately these are just causing a lot of noise and not actually breaking anything or we would be in a world of hurt.

@timnolte
Copy link
Author

@trsteel88 & @G-Rath I'm working on a Composer patch that can be applied using https://github.com/cweagans/composer-patches that will update Timber to the 1.44 release of Twig. I'm not sure how maintainable this is going to be for the long term. I'm going to need to confirm the items that @JohnnyBravoTheBest reported as well and see if I can patch those as well.

@rmens
Copy link
Contributor

rmens commented Aug 22, 2022

@timnolte Can't you make a PR here? I have a staging-site with Timber 1.x that I can test it on. Pretty sure we can get it merged is it's well tested.

@timnolte
Copy link
Author

@rmens well, I'm not sure if it's going to do a lot of good as it seems like there may not be any plans to invest time into 1.x anymore in favor of 2.x. #2548 (comment)

@gchtr
Copy link
Member

gchtr commented Aug 22, 2022

@timnolte Sorry we didn’t answer on this one. Actually, we would be glad if you could make a PR for this.

As much as we would have liked to release Timber version 2 sooner, it takes us way longer than expected. To support the transition phase, we’ll probably have to support PHP 8 in Timber version 1 as well. Though we probably won’t add more features to Timber v1.

It’s much easier for us if we can review a pull request and merge it in than doing all the work from the ground up.

@timnolte
Copy link
Author

@gchtr sounds good. I can look at preparing a PR.

@timnolte
Copy link
Author

@JohnnyBravoTheBest are you sure the items you've reported are not PHP 8.1 warnings instead of PHP 8.0? I'm not seeing these returned in my logs, and they still aren't being reported by the PHP Code Sniffer library(though that might just be because the tests are missing).

@rubencherbit
Copy link

@timnolte We have same warnings and we are in PHP 8.0.19

@aj-adl
Copy link
Contributor

aj-adl commented Sep 1, 2022

@timnolte Confirming we're getting the same issues on 8.0.x of PHP.

They are 'warnings' in 8.0 and promoted to actual errors (ie: not easily ignored / suppressible) in 8.1. We're in a similar boat (Agency, 50+ sites in the wild) so some kind of update to the 1.x branch to support 8.0 would be great.

I think 8.1 compat is a whole other target (8.1 is HARSH), but getting to 8.0 buys another year to sort it out before it's full EOL.

@timnolte
Copy link
Author

timnolte commented Sep 2, 2022

@aj-adl ah, thanks for confirming the difference here. Generally we are only monitoring and capturing errors not warnings which explains why I haven't seen them. I'm only testing for errors in PHP 8.0.

@rmens
Copy link
Contributor

rmens commented Sep 3, 2022

Note that PHP 8.0 won't have active support in 2 months, and only has extended security support for a year and two months. Aiming for PHP 8.1 seems to be the right thing at this point in time.

@timnolte
Copy link
Author

timnolte commented Sep 3, 2022

@rmens both 8.0 and 8.1 need to be accounted for. For most people the active security support is the real issue.

@gchtr
Copy link
Member

gchtr commented Oct 12, 2022

We just released a new version 1.21.0 that adds support for PHP 8.0 and 8.1: https://github.com/timber/timber/releases/tag/1.21.0.

It will soon be published to the WordPress plugin repository as well.

@gchtr gchtr closed this as completed Oct 12, 2022
@thangaraj-moorthi
Copy link

thangaraj-moorthi commented Oct 12, 2022

HI @gchtr
I've tried your latest version 1.21.0
I'm facing Fatal error: Uncaught Error: Class "Routes" not found in my twig.php
Could give me an idea to fix this on my end please? or its global issue on this new version ?

@gchtr
Copy link
Member

gchtr commented Oct 12, 2022

@thangaraj-fuint Please fill out a new issue with all the info that is requested in the issue template. (WordPress version, installation method, etc.)

@thangaraj-moorthi
Copy link

Thanks @gchtr
Created the new issue, please take a look: #2652

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

No branches or pull requests

9 participants