Fixed PHP version requirement fails when installing add-on

TickTackk

Well-known member
Affected version
2.1.9
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.
 
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.
 
Back
Top Bottom