core
core copied to clipboard
PHP 8.1 Deprecation warnings
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 Please update to Bolt 5.1, and let us know if this issue persists. :-)
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
OK, the upgrade to Bolt 5.1 is now complete, but unfortunately the issue persists.
Yeah, this is still an issue:
https://github.com/bolt/core/blob/89104aa4ca6e9354f62247053e8336940cb97795/src/Storage/SelectQuery.php#L113
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
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
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)
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. :-/
I believe it is related to the PHP settings, although I have not yet been able to find which one it actually is...
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 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
Yes, I'm using both the runtime component and Sentry.
@bobdenotter / @benr77 This can be closed as it should be fixed with https://github.com/bolt/core/pull/3307.
Yes, confirmed - I've just applied the update and the issue is resolved.
Thank you.