WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #46411, comment 3


Ignore:
Timestamp:
03/04/2019 03:13:15 PM (13 months ago)
Author:
nerrad
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #46411, comment 3

    initial v1  
    1 The issue appears to be that the `version_compare` check fails with certain php version strings reported by `phpversion()`.
     1I incorrectly informed @cristiano.zanca that this was a bug because in the test I did I included the `PHP Version` string :( . 
    22
    33Example:
     
    77}}}
    88
    9 Reports `false`.
     9Instead, the correct test doing this:
    1010
    11 So there will need to be some sanitization of the string returned by `phpversion()`
     11{{{
     12var_dump( version_compare( '7.2.15-1+0~20190209065123.16+stretch~1.gbp3ad8c0', '7.1', '>=' ) );
     13}}}
     14
     15returns the expected `true` value.
     16
     17For 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.
    1218
    1319Alternatively, 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: