Skip to content

PHP 8.4 Compatibility #5946

Closed
Closed

Description

@swissspidy

Note

PSA: If you see warnings when running WP-CLI on PHP 8.4, please update to the latest nightly build first: wp cli update --nightly


This is a general tracking issue for PHP 8.4 compatibility throughout WP-CLI.

Some known issues / blockers:

Broken unit/Behat tests

Unit tests and Behat tests are currently not working on PHP 8.4 due to the bundled Requests v1 triggering an error:

Update: looks like this was fixed in PHP 8.4, so there is no longer any fatal error.

Details
TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_HEADERFUNCTION, no array or string given

/home/runner/work/wp-cli/wp-cli/bundle/rmccue/requests/src/Transport/Curl.php:223
/home/runner/work/wp-cli/wp-cli/bundle/rmccue/requests/src/Requests.php:469

Maybe a good time to migrate to Requests v2?

This is also an issue in v2 though:

TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_HEADERFUNCTION, no array or string given

/tmp/wordpress/wp-includes/Requests/src/Transport/Curl.php:223
/tmp/wordpress/wp-includes/Requests/src/Requests.php:469

So this needs to get fixed in https://github.com/WordPress/Requests

Related:

Deprecation notices in Composer

Some examples:

Deprecation Notice: Composer\Pcre\Preg::replace(): Implicitly marking parameter $count as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/bin/composer/vendor/composer/pcre/src/Preg.php:150
Deprecation Notice: Composer\Pcre\Preg::replaceCallback(): Implicitly marking parameter $count as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/bin/composer/vendor/composer/pcre/src/Preg.php:177
Deprecation Notice: Composer\Pcre\Preg::replaceCallbackArray(): Implicitly marking parameter $count as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/bin/composer/vendor/composer/pcre/src/Preg.php:207
Deprecation Notice: JsonSchema\Constraints\BaseConstraint::__construct(): Implicitly marking parameter $factory as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/bin/composer/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php:41
Deprecation Notice: JsonSchema\Constraints\BaseConstraint::addError(): Implicitly marking parameter $path as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/bin/composer/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php:46

Question is whether those are only shown during development or also when using wp package *.

Activity

  1. swissspidy commented on Jul 11, 2024

    @swissspidy
    MemberAuthor

    So there is a new 5.3.0 release of justinrainbow/json-schema that resolves the deprecation notices, but it now requires PHP 7.1 as that's when nullable types were introduced. WP-CLI doesn't use it directly, but it's a dependency of composer/composer.

    All our tests seem to be passing on PHP 8.4 right now, so that's a good sign 👍

  2. ernilambar commented on Jul 16, 2024

    @ernilambar
    Member

    Notice in php-cli-tools:

    PHP Deprecated:  cli\Table::__construct(): Implicitly marking parameter $headers as nullable is deprecated, the explicit nullable type must be used instead in vendor/wp-cli/php-cli-tools/lib/cli/Table.php on line 47
    Deprecated: cli\Table::__construct(): Implicitly marking parameter $headers as nullable is deprecated, the explicit nullable type must be used instead in vendor/wp-cli/php-cli-tools/lib/cli/Table.php on line 47
    
  3. swissspidy commented on Oct 1, 2024

    @swissspidy
    MemberAuthor

    Over at WordPress Trac, the following issue with the testing setup across all WP-CLI repos was raised:

    it looks like CI isn't set up to fail on PHP deprecations in all circumstances, which allows for new issues to be introduced without anybody noticing for some of the packages.

    Different fixes are required depending on the PHPUnit versions, so it might not be super trivial to achieve this.

    See also:

  4. mrsdizzie commented on Nov 14, 2024

    @mrsdizzie
    Member

    There are still several places we mark a parameter as nullable and it triggers a warning on PHP 8.4, like:

    PHP 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 vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php
    

    As mentioned above, the suggested fix requires PHP 7.1 but I believe PHP 5.6 is still the minimum version for wp-cli.

    Do we want to settle on a fix for these?

  5. swissspidy commented on Nov 14, 2024

    @swissspidy
    MemberAuthor

    We actually fixed that one already, but we haven‘t made a new nightly build yet

  6. swissspidy commented on Nov 26, 2024

    @swissspidy
    MemberAuthor

    The nightly build is finally fixed now 🎉

    One obvious deprecation warning that's left is from mustache/mustache

  7. michaelw85 commented on Jan 30, 2025

    @michaelw85

    We actually fixed that one already, but we haven‘t made a new nightly build yet

    In version 2.11.0 I'm still seeing this error:

    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:///opt/homebrew/Cellar/wp-cli/2.11.0/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php on line 1958
    
  8. swissspidy commented on Jan 30, 2025

    @swissspidy
    MemberAuthor

    @michaelw85 This is expected. You can update to the latest nightly build in the meantime.

  9. michaelw85 commented on Jan 30, 2025

    @michaelw85

    Sorry, I just noticed "nightly build" 😅 I thought it was already released. Is there anything I can contribute to help get 8.4 support released?

  10. swissspidy commented on Jan 30, 2025

    @swissspidy
    MemberAuthor

    I don't think so.

    The remaining issue with the mustache library needs some discussion among maintainers/committers first to get consensus.

    Otherwise just use the nightly build for now, they are usually very stable :-)

  11. hooch commented on Feb 10, 2025

    @hooch

    Also seeing

    Deprecated: WpOrg\Requests\Cookie::parse_from_headers(): Implicitly marking parameter $origin as nullable is deprecated, the explicit nullable type must be used instead in phar:///opt/homebrew/Cellar/wp-cli/2.11.0/bin/wp/vendor/wp-cli/wp-cli/bundle/rmccue/requests/src/Cookie.php on line 474
    
  12. swissspidy commented on Feb 10, 2025

    @swissspidy
    MemberAuthor

    This was already addressed in 887b0bb / the upcoming v2.12.0. Please update to the latest nightly.

  13. yarcowang commented on Feb 13, 2025

    @yarcowang

    Update:
    Disappointed. I wish it could work.
    But it seems phar has its own error_reporting settings, external settings does not affect the internal settings.
    That must be the design problem (phar) ---- user shoud have the highest priority to define app's actions.

    ====
    I also met this problem... but if you don't mind to add a auto_prepend_file file, you can solve it by disable E_DEPRECATED.
    Image

    Normally we don't care about it in usage but turn on it in development as a traditional PHP developer.

    (But the phar path WP_CLI phar path: /Users/yarco/init is changed to a different location. Not sure whether it will take an impact or not.)

    Or maybe set an alias in bash (would be better if you don't want to affect the global environment):

    alias wp="php -dauto_prepend_file=/Users/yarco/init/auto_prepend_file.php /opt/homebrew/bin/wp"
  14. SirLouen commented on Apr 25, 2025

    @SirLouen

    I repost here #6085

    Judging from the last comments, I can't really see in which point this is currently.

  15. swissspidy commented on Apr 25, 2025

    @swissspidy
    MemberAuthor

    We‘re planning on forking the mustache library with our existing patches that we already have. A new WP-CLI release is coming out soon.

  16. SirLouen commented on Apr 25, 2025

    @SirLouen

    We‘re planning on forking the mustache library with our existing patches that we already have. A new WP-CLI release is coming out soon.

    Ok I better see the problem now: Last version is from Aug 2024 and it seems that PHP implementation of Mustache is seriously outdated.

    So I'm assuming that the main alternative was going for lightncandy or forking PHP Mustache and sorting the deprecation issues. Do we have a link to the Mustache fork already?

  17. swissspidy commented on Apr 26, 2025

    @swissspidy
    MemberAuthor

    It‘s in preparation.

  18. swissspidy commented on May 6, 2025

    @swissspidy
    MemberAuthor

    The remaining issue with the Mustache library was fixed by #6090

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions