Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP version_compare Argument #3 ($operator) must be a valid comparison #425

Open
kseones opened this issue Jun 15, 2024 · 0 comments
Open

Comments

@kseones
Copy link

kseones commented Jun 15, 2024

Uncaught ValueError: version_compare(): Argument #3 ($operator) must be a valid comparison in /library/Zend/Xml/Security.php:172

    $isVulnerableVersion = (
        version_compare(PHP_VERSION, '5.5.22', 'lt')
        || (
            version_compare(PHP_VERSION, '5.6', 'ge')
            && version_compare(PHP_VERSION, '5.6.6', 'lt')
        )
    );

In PHP 8.1, the version_compare() function is made more strict with the operator parameter.

In PHP 8.0, this was made to throw a ValueError exception if an unknown parameter was passed, as part of the internal function exception handling changes.

In PHP 8.1, this is further restricted to disallow partial values for operator parameter.

version_compare(1, 2, '');
version_compare(1, 2, '!');
version_compare(1, 2, 'g');
version_compare(1, 2, 'l');
version_compare(1, 2, 'n');

All of the statements above are were allowed in PHP 8.0, and are no longer allowed in PHP 8.1. These values are undocumented values from the documentation.

Please see here: https://php.watch/versions/8.1/version_compare-operator-restrictions

It seems that all other version_compare functions are ok but only not in Security.php and ControllerTestCase.php:

grep -r "version_compare" library/Zend/*
library/Zend/Barcode/Renderer/Image.php: if (version_compare(PHP_VERSION, '8.1.0', '>=')) {
library/Zend/Db/Adapter/Oracle.php: if (($version === null) || version_compare($version, '9.0.0', '>=')) {
library/Zend/Db/Adapter/Pdo/Mysql.php: && version_compare(PHP_VERSION, '5.3.6', '<')
library/Zend/Db/Adapter/Pdo/Oci.php: if (($version === null) || version_compare($version, '9.0.0', '>=')) {
library/Zend/Loader/AutoloaderFactory.php: if (version_compare(PHP_VERSION, '5.3.7', '>=')) {
library/Zend/Loader/Autoloader.php: uksort($versions, 'version_compare');
library/Zend/Loader/StandardAutoloader.php: if (version_compare(PHP_VERSION, '5.3.2', '>=')) {
library/Zend/Log/Filter/Priority.php: return version_compare($event['priority'], $this->_priority, $this->_operator);
library/Zend/Mobile/Push/Message/Gcm.php: if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
library/Zend/Mobile/Push/Apns.php: if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
library/Zend/Pdf/Parser.php: if (version_compare($pdfVersion, '0.9', '<') ||
library/Zend/Pdf/Parser.php: version_compare($pdfVersion, '1.61', '>=')
library/Zend/Pdf.php: if ($root->Version !== null && version_compare($root->Version->value, $pdfHeaderVersion, '>')) {
library/Zend/Pdf.php: $versionIs_1_2_plus = version_compare($root->Version->value, '1.1', '>');
library/Zend/Pdf.php: $versionIs_1_2_plus = version_compare($pdfHeaderVersion, '1.1', '>');
library/Zend/Service/LiveDocx.php: return version_compare($version, $this->getVersion());
library/Zend/Stdlib/CallbackHandler.php: $isPhp54 = version_compare(PHP_VERSION, '5.4.0rc1', '>=');
library/Zend/Test/PHPUnit/ControllerTestCase.php: if (version_compare(PHPUnit_Runner_Version::id(), '3.3.0', 'lt')) {
library/Zend/Test/PHPUnit/ControllerTestCase.php: } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.3.3', 'lt')) {
library/Zend/Test/PHPUnit/Constraint/Redirect.php:if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) {
library/Zend/Test/PHPUnit/Constraint/Redirect.php:} elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) {
library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php:if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) {
library/Zend/Test/PHPUnit/Constraint/ResponseHeader.php:} elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) {
library/Zend/Test/PHPUnit/Constraint/DomQuery.php:if (version_compare(PHPUnit_Runner_Version::id(), '4.1', '>=')) {
library/Zend/Test/PHPUnit/Constraint/DomQuery.php:} elseif (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) {
library/Zend/Version.php: return version_compare($version, strtolower(self::VERSION));
library/Zend/Wildfire/Plugin/FirePhp.php: if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
library/Zend/Xml/Security.php: version_compare(PHP_VERSION, '5.5.22', 'lt')
library/Zend/Xml/Security.php: version_compare(PHP_VERSION, '5.6', 'ge')
library/Zend/Xml/Security.php: && version_compare(PHP_VERSION, '5.6.6', 'lt')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant