core icon indicating copy to clipboard operation
core copied to clipboard

PHP 8.1 Deprecation warnings

Open benr77 opened this issue 3 years ago • 12 comments

PHP is outputting deprecation notices when run via the CLI.

PHP Deprecated:  Optional parameter $qb declared before required parameter 
$utils is implicitly treated as a required parameter in 
vendor/bolt/core/src/Storage/SelectQuery.php on line 111

Details

Question Answer
Relevant Bolt Version 5.0.7
Install type Composer
BC Break no
PHP version 8.1

Reproduction

Upgrading to PHP 8.1 and my app's cronjobs start throwing the above error.

benr77 avatar Dec 10 '21 06:12 benr77

@benr77 Please update to Bolt 5.1, and let us know if this issue persists. :-)

bobdenotter avatar Dec 16 '21 18:12 bobdenotter

I have done the upgrade but the first thing I encountered was an issue running the Doctrine migration, which I have just reported in #3021

Thanks

benr77 avatar Dec 17 '21 11:12 benr77

OK, the upgrade to Bolt 5.1 is now complete, but unfortunately the issue persists.

benr77 avatar Dec 18 '21 09:12 benr77

Yeah, this is still an issue:

https://github.com/bolt/core/blob/89104aa4ca6e9354f62247053e8336940cb97795/src/Storage/SelectQuery.php#L113

bobvandevijver avatar Jan 20 '22 07:01 bobvandevijver

When and where are you encountering these? So far, it seems to be working fine for me on PHP 8.1

bin/console bolt:info

 Bolt version: 5.1.3

 * Install type: Packaged distribution
 * Database: sqlite 3.37.2 (with JSON)
 * PHP version: 8.1.2
 * Symfony version: v5.4.4
 * Operating System: Darwin - 21.2.0
 * Memory limit: 1024M

bobdenotter avatar Feb 17 '22 15:02 bobdenotter

It's a problem with the method signature - the optional parameter is first, and it must be last.

PHP Deprecated:  Optional parameter $qb declared before required parameter $utils is implicitly treated 
as a required parameter in /var/www/html/vendor/bolt/core/src/Storage/SelectQuery.php on line 112
 Bolt version: 5.1.3
 
 * Install type: Packaged distribution
 * Database: mysql 8.0.22 - app_db_1 via TCP/IP (with JSON)
 * PHP version: 8.1.1
 * Symfony version: v5.4.4
 * Operating System: Linux - 5.4.0-99-generic
 * Memory limit: 6g

I see the different PHP version - you have 8.1.2 and I have 8.1.1 but this should not make any difference it's still a deprecation.

Thanks

benr77 avatar Feb 17 '22 15:02 benr77

The problem is not that it doesn't work, the problem is that is deprecated and should be fixed before PHP 9 (or maybe 8.2, not sure)

bobvandevijver avatar Feb 17 '22 17:02 bobvandevijver

Hmm, i'm not seeing those deprecations, though.

I agree they should be fixed (if they're in our code), but it's easier if i can actually see them. :-/

bobdenotter avatar Feb 25 '22 09:02 bobdenotter

I believe it is related to the PHP settings, although I have not yet been able to find which one it actually is...

bobvandevijver avatar Feb 28 '22 12:02 bobvandevijver

I'm the same actually - I run a cronjob and it emits this deprecation message each time it's run, but I cannot for the life of me figure out which setting is needed to mute the notice. Using ~ E_DEPRECATED does not work.

I have error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT set in php.ini on my production box for CLI scripts.

Does Symfony mess with the deprecation reports somehow?

benr77 avatar Mar 01 '22 07:03 benr77

@benr77 Are you using Sentry? That might also be touching the error reporting level.

But yes, Symfony messes with the error_reporting:

  • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Runtime/Internal/BasicErrorHandler.php#L42
  • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/ErrorHandler/Debug.php
  • https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/HttpKernel/Kernel.php#L458

bobvandevijver avatar Mar 01 '22 07:03 bobvandevijver

Yes, I'm using both the runtime component and Sentry.

benr77 avatar Mar 01 '22 10:03 benr77

@bobdenotter / @benr77 This can be closed as it should be fixed with https://github.com/bolt/core/pull/3307.

bobvandevijver avatar Aug 31 '22 15:08 bobvandevijver

Yes, confirmed - I've just applied the update and the issue is resolved.

Thank you.

benr77 avatar Aug 31 '22 16:08 benr77