wp-cli / extension-command

Manages plugins and themes, including installs, activations, and updates.
MIT License
90 stars 79 forks source link

New get_wporg_data code uses PHP 8+ feature #431

Closed mrsdizzie closed 3 months ago

mrsdizzie commented 3 months ago

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

https://github.com/wp-cli/extension-command/blob/189e2648cec5443bb7041660be4c37014b61fd34/src/Plugin_Command.php#L866

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

swissspidy commented 3 months ago

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?

ernilambar commented 3 months ago

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.