Skip to content

New get_wporg_data code uses PHP 8+ feature #431

Closed

Description

@mrsdizzie

The new function get_wporg_data uses str_contains that is PHP 8 only: https://www.php.net/manual/en/function.str-contains.php

if ( str_contains( $r_body, 'pubDate' ) ) {

Newer versions of WordPress have a Pollyfill for this so maybe people are more accustom to using it without error:

https://github.com/WordPress/wordpress-develop/blob/656e87bab960a9e8ed4616476519eda4199511d1/src/wp-includes/compat.php#L475

But WP-CLI minimum supported version is WordPress 3.7

This should probably be replaced with a strpos($r_body, 'pubDate') !== false

A larger issue is that this wasn't caught by phpcs. Looking in the vendor dir for wp-cli-tests the last entry in the changelog for php-compatibility is 2019 😬

Is this because they haven't made a release since then? And all development is done on the develop branch? https://github.com/PHPCompatibility/PHPCompatibility/

I'm not really familiar with the details of how composer installs packages, but seems that something isn't catching these errors which should. Possible there are other PHP compatibility errors that aren't being caught.

I can submit a PR for this particular issue if that seems right

Activity

  1. added a commit that references this issue on Aug 14, 2024
    b14d625
  2. swissspidy commented on Aug 14, 2024

    @swissspidy
    Member

    I'm not really familiar with the details of how composer installs packages, but seems that something isn't catching these errors which should. Possible there are other PHP compatibility errors that aren't being caught.

    That sounds strange indeed 🤔 Mind opening an issue on the wp-cli-tests repo so we can look into it further?

  3. ernilambar commented on Aug 15, 2024

    @ernilambar
    Member

    I'm not really familiar with the details of how composer installs packages, but seems that something isn't catching these errors which should. Possible there are other PHP compatibility errors that aren't being caught.

    That sounds strange indeed 🤔 Mind opening an issue on the wp-cli-tests repo so we can look into it further?

    Latest tagged version 9.3.5 of PHPCompatibility does not know about PHP 8. When I tried with dev-develop version, those functions are detected.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions