Fixed PHP version requirement fails when installing add-on

Affected version
2.1.9

TickTackk

Well-known member
In file src\XF\AddOn\Manager.php
PHP:
        if (strpos($productKey, 'php-ext/') === 0)
            {
                $parts = explode('/', $productKey, 2);
                if (isset($parts[1]))
                {
                    $enabled = extension_loaded($parts[1]);

                    if ($version === '*')
                    {
                        $versionValid = true;
                    }
                    else
                    {
                        $versionValid = (version_compare(phpversion($parts[1]), $version) === 1);
                    }
                }
            }
            else if ($productKey === 'php')
            {
                $enabled = true;
                $versionValid = (version_compare(phpversion(), $version) === 1);
            }
            else if ($productKey === 'mysql')
            {
                $mySqlVersion = \XF::db()->getServerVersion();
                if ($mySqlVersion)
                {
                    $enabled = true;
                    $versionValid = (version_compare(strtolower($mySqlVersion), $version) === 1);
                }
            }
should be:
PHP:
        if (strpos($productKey, 'php-ext/') === 0)
        {
            $parts = explode('/', $productKey, 2);
            if (isset($parts[1]))
            {
                $enabled = extension_loaded($parts[1]);

                if ($version === '*')
                {
                    $versionValid = true;
                }
                else
                {
                    $versionValid = \version_compare(phpversion($parts[1]), $version, 'ge');
                }
            }
        }
        else if ($productKey === 'php')
        {
            $enabled = true;
            $versionValid = \version_compare(phpversion(), $version, 'ge');
        }
        else if ($productKey === 'mysql')
        {
            $mySqlVersion = \XF::db()->getServerVersion();
            if ($mySqlVersion)
            {
                $enabled = true;
                $versionValid = \version_compare(strtolower($mySqlVersion), $version, 'ge');
            }
        }
Or else when the required PHP version is set to 7.2.29 and the installed PHP version is 7.2.29, XF will not allow installing the add-on.

Edit: this might also apply to PHP extension versions or MySQL.
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.1.10).

Change log:
Properly check required PHP, PHP extension, and MySQL versions during add-on installation
There may be a delay before changes are rolled out to the XenForo Community.
 
Top