wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

Deprecated: YoastSEO_Vendor\Symfony\Component\DependencyInjection\Container::__construct(): Implicitly marking parameter $parameterBag as nullable is deprecated in PHP 8.4

Open bobbingwide opened this issue 1 year ago • 19 comments

  • [x] I've read and understood the contribution guidelines.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

This message is produced with PHP 8.4.1

Deprecated: YoastSEO_Vendor\Symfony\Component\DependencyInjection\Container::__construct(): Implicitly marking parameter $parameterBag as nullable is deprecated, the explicit nullable type must be used instead in C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\vendor_prefixed\symfony\dependency-injection\Container.php on line 60

To Reproduce

Step-by-step reproduction instructions

  1. Switch to PHP 8.4.1
  2. Ensure wordpress-seo is activated
  3. run a WP-CLI command such as wp plugin status wordpress-seo
  4. Notice several Deprecated messages... one of which is produced for WordPress SEO; the other 3 are from WP-CLI

Expected results

Plugin wordpress-seo details: Name: Yoast SEO Status: Active Version: 23.9 Author: Team Yoast Description: The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more.

Actual results

C:\apache\htdocs\wordpress\wp-content\plugins\oik>wp plugin status wordpress-seo

Deprecated: WP_CLI\Runner::get_subcommand_suggestion(): Implicitly marking parameter $root_command as nullable is deprecated, the explicit nullable type must be used instead in phar://C:/d_drive/dos/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php on line 1958 Deprecated: YoastSEO_Vendor\Symfony\Component\DependencyInjection\Container::__construct(): Implicitly marking parameter $parameterBag as nullable is deprecated, the explicit nullable type must be used instead in C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\vendor_prefixed\symfony\dependency-injection\Container.php on line 60 Deprecated: Mustache_Engine::loadSource(): Implicitly marking parameter $cache as nullable is deprecated, the explicit nullable type must be used instead in phar://C:/d_drive/dos/wp-cli.phar/vendor/mustache/mustache/src/Mustache/Engine.php on line 727 Deprecated: Mustache_Parser::buildTree(): Implicitly marking parameter $parent as nullable is deprecated, the explicit nullable type must be used instead in phar://C:/d_drive/dos/wp-cli.phar/vendor/mustache/mustache/src/Mustache/Parser.php on line 73 Plugin wordpress-seo details: Name: Yoast SEO Status: Active Version: 23.9 Author: Team Yoast Description: The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more.

Screenshots, screen recording, code snippet

See output above.

Technical info

  • If relevant, which editor is affected (or editors):
  • [ ] Block Editor
  • [ ] Gutenberg Editor
  • [ ] Elementor Editor
  • [ ] Classic Editor
  • [ ] Other:
  • Which browser is affected (or browsers):
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Safari
  • [ ] Other:

Used versions

  • Device you are using: Dell laptop
  • Operating system: Windows
  • PHP version: 8.4.1
  • WordPress version: 6.7.1
  • WordPress Theme: n/a
  • Yoast SEO version: 23.9
  • Gutenberg plugin version:
  • Elementor plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug:

For my environment the fix is easy. Add a ? to line 60 of the file mentioned.

public function __construct(?\YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag = null)

bobbingwide avatar Nov 23 '24 17:11 bobbingwide

I've received several other Deprecated messages that should also be addressed.

[23-Nov-2024 17:25:52 UTC] PHP Deprecated: YoastSEO_Vendor\League\OAuth2\Client\Provider\AbstractProvider::authorize(): Implicitly marking parameter $redirectHandler as nullable is deprecated, the explicit nullable type must be used instead in C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\vendor_prefixed\league\oauth2-client\src\Provider\AbstractProvider.php on line 416 [23-Nov-2024 17:25:52 UTC] PHP Deprecated: YoastSEO_Vendor\GuzzleHttp\Client::getConfig(): Implicitly marking parameter $option as nullable is deprecated, the explicit nullable type must be used instead in C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\vendor_prefixed\guzzlehttp\guzzle\src\Client.php on line 181 [23-Nov-2024 17:25:52 UTC] PHP Deprecated: YoastSEO_Vendor\GuzzleHttp\ClientInterface::getConfig(): Implicitly marking parameter $option as nullable is deprecated, the explicit nullable type must be used instead in C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\vendor_prefixed\guzzlehttp\guzzle\src\ClientInterface.php on line 77

bobbingwide avatar Nov 23 '24 17:11 bobbingwide

Hi @bobbingwide

Thanks for creating the issue.

As WP had added “beta support” for PHP 8.3 in version 6.4 and there are no mentions of 8.4 till now, the deprecation message for PHP 8.4 is expected. Our team will fix deprecated messages for PHP 8.4 when WP is fully compatible. As there are no mentions of PHP 8.4 within the WP document shared above, it may take some time.

If the issue occurs with PHP 8.3, please let us know.

josevarghese avatar Nov 24 '24 12:11 josevarghese

WordPress 6.7 (and 6.8) had "beta" support for PHP 8.4 added. And since there's no major WordPress releases for this year and PHP 8.3 active support ending at the end of the year, it would be great to have the major players in WordPress plugin-space to update their plugins to be PHP 8.4 compatible. Even though these deprecation errors are coming from third party packages 🙂

todeveni avatar Apr 29 '25 04:04 todeveni

Yeah, I'm currently having to manually patch Yoast and it sucks. Since the criteria for beta support is 10% adoption of PHP 8.4 for WordPress sites this issue causes a bit of a catch 22 for people who are scared of deprecation notices.

https://make.wordpress.org/core/2025/04/09/php-8-support-clarification/

stefanfisk avatar Aug 10 '25 10:08 stefanfisk

Please fix this.

Dekadinious avatar Sep 29 '25 06:09 Dekadinious

@josevarghese If I understand you correctly you are waiting for WP to add official beta support for PHP 8.4? If so I'm a bit confused, since that happened in WP 6.7 which was released about a week before your comment. The document you linked states In WordPress 6.7: Added beta support for PHP 8.4.

stefanfisk avatar Sep 30 '25 04:09 stefanfisk

@stefanfisk To clarify, WordPress 6.7 introduced beta support for PHP 8.4, but this is not equivalent to full, stable support. Our development team will review and decide on PHP 8.4 support in one of our upcoming sprints, based on stability and broader adoption.

In the meantime, we welcome community contributions with open arms. Should you wish to contribute, please refer to our contributing guidelines here.

josevarghese avatar Sep 30 '25 06:09 josevarghese

Manual fix:

in wordpress-seo/vendor_prefixed/symfony/dependency-injection/Container.php

    public function __construct(\YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag = null)
    {
        $this->parameterBag = $parameterBag ?: new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag();
    }

becomes

    public function __construct(?\YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag = null)
    {
        $this->parameterBag = $parameterBag ?: new \YoastSEO_Vendor\Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag();
    }

Yoast composer.lock tells us that yoast is using symfony/dependency-injection v3.4.47 which last commit is 5 years old, no php 8.4 at that time.

I guess the work would be to upgrade this package. symfony/dependency-injection 5.4 is the last version that supports php7.4 and would be a good candidate.

axi avatar Oct 07 '25 16:10 axi

@josevarghese I understand you can't prioritize on a deprecation, but saying that you will decide on PHP8.4 support seems weird to me. Do you see a future where you decide not to support PHP8.4 ? 😂

axi avatar Oct 07 '25 16:10 axi

@axi, we are already working on the upgrade of the symfony/dependency-injection to 5.4 at here: https://github.com/Yoast/wordpress-seo/pull/21905

josevarghese avatar Oct 08 '25 11:10 josevarghese

Any updates? The above PR is there since 2024.....

maciejmackowiak avatar Oct 22 '25 17:10 maciejmackowiak

We're trying to update to PHP 8.4 and this is the last blocker. 🙏

archon810 avatar Oct 22 '25 17:10 archon810

8.5 is already coming in a couple of weeks...

peters97 avatar Oct 27 '25 08:10 peters97

Permanent fixes you can apply now (hot‑patch) just by addding a ?

On File: wp-content/plugins/wordpress-seo/vendor_prefixed/guzzlehttp/guzzle/src/ClientInterface.php find public function getConfig($option = null); add ? before $option so it become : public function getConfig(?$option = null);

Similarly On File wp-content/plugins/wordpress-seo/vendor_prefixed/guzzlehttp/guzzle/src/Client.php Find public function getConfig($option = null); add ? before $option so it become : public function getConfig(?$option = null);

Simialry on File wp-content/plugins/wordpress-seo/vendor_prefixed/league/oauth2-client/src/Provider/AbstractProvider.php Find public function authorize(array $options = [], callable $redirectHandler = null) add ? before $callable so it become :

Why this works: PHP 8.4 deprecates implicit nullability; making $option explicitly nullable (?string) resolves the warning at parse time. This is the exact pattern PHP recommends and works on PHP 7.1+.

karan4official avatar Nov 06 '25 09:11 karan4official

@karan4official , we've been running on PHP 8.4 without issues for ages, but since yesterday, we're seeing an error from Yoast. Any idea why this is suddenly happening now? Did they release a new update recently that might have caused this?

0xgthuva avatar Nov 08 '25 11:11 0xgthuva

These deprecation errors have been sitting around for way too long.

lawrencejohnson avatar Nov 09 '25 15:11 lawrencejohnson

Please inform the customer of conversation # 1328883 when this conversation has been closed.

amboutwe avatar Nov 18 '25 18:11 amboutwe

#21905 has been merged last week, it should be fine soon.

axi avatar Nov 18 '25 21:11 axi

See https://github.com/Yoast/wordpress-seo/releases/tag/26.5-RC1

axi avatar Nov 18 '25 21:11 axi