Skip to content

New get_wporg_data code uses PHP 8+ feature #431

@mrsdizzie

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

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