Opened 7 years ago
Closed 7 years ago
#46411 closed defect (bug) (worksforme)
Requirements PHP Version plugin error with False positive
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 5.2 |
| Component: | Plugins | Keywords: | has-screenshots |
| Focuses: | Cc: |
Description
Hi, in a local LEMP with NGINX and no APACHE,
phpinfo() show this PHP version PHP Version 7.2.15-1+0~20190209065123.16+stretch~1.gbp3ad8c0
I want to install and test my plugin https://wordpress.org/plugins/woo-fattureincloud/ that has minimum requirements PHP 7.1
=== WooCommerce Fattureincloud === Contributors: cristianozanca Tags: fattureincloud, fattura elettronica, fatturazione elettronica Requires at least: 4.6 Tested up to: 5.1 Requires PHP: 7.1
Change History (5)
This ticket was mentioned in Slack in #core-php by cristiano.zanca. View the logs.
7 years ago
#3
@
7 years ago
I incorrectly informed @cristiano.zanca that this was a bug because in the test I did I included the PHP Version string :( .
Example:
var_dump( version_compare( 'PHP Version 7.2.15-1+0~20190209065123.16+stretch~1.gbp3ad8c0', '7.1', '>=' ) );
Instead, the correct test doing this:
var_dump( version_compare( '7.2.15-1+0~20190209065123.16+stretch~1.gbp3ad8c0', '7.1', '>=' ) );
returns the expected true value.
For future proofing against possible string issues we _could_ still use the constants as mentioned below but for all intents and purposes this does not appear to be a bug right now.
Alternatively, using the php version constants might be better here: PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION. That will ensure we're only comparing on the important values, so something like:
$server_php_version = implode( '.', array( PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION ) ); $compatible_php = ( empty( $plugin['requires_php'] ) || version_compare($server_php_version, $plugin['requires_php'], '>=' ) );
#4
@
7 years ago
The PHP_VERSION_ID constant is also a possibility.
http://php.net/manual/en/function.phpversion.php#example-567
#5
@
7 years ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
Closing as per discussion on Slack: https://wordpress.slack.com/archives/C60K3MP2Q/p1551712706035200


Mark Wolinski says it may be the additional text on the PHP version number that’s causing the issue, @nerrad add that "The check is being done via:
version_compare( phpversion(), $plugin['requires_php'], '>=' )"