humhub / updater

Upgrade your HumHub installation to the latest version in a few clicks.
8 stars 12 forks source link

Check minimum PHP version #20

Closed ArchBlood closed 2 years ago

ArchBlood commented 3 years ago

On update it should check for the minimum version of PHP needed for the HumHub version you're updating to

luke- commented 3 years ago

Good point, we somehow determine the "new minimum PHP version".

ArchBlood commented 3 years ago

I believe using YiiRequirementChecker as a backbone wouldn't hurt anything of course I'm always open to other options :thinking:

ArchBlood commented 3 years ago

Just an example maybe? I'm sure that there is a much easier way of doing this but just an idea @luke- :smile:

Example

updater/modules/packageinstaller/controllers/InstallController.php

    public function actionCheckPhp()
    {
        $requirementsChecker = new \YiiRequirementChecker();
        $requirements = [
            [
                'name' => 'PHP Minimum Version',
                'mandatory' => true,
                'condition' => PHP_VERSION('7.1'),
                'memo' => 'PHP version "7.1" required',
            ],
        ];
        $requirementsChecker->check($requirements)->render();
    }
luke- commented 2 years ago

@yurabakhtin Can you maybe implement such a check.

I think the minimum PHP versions of the respective major releases can be hardcoded in the updater module. https://docs.humhub.org/docs/admin/requirements

yurabakhtin commented 2 years ago

@luke- What do you think if we will keep min PHP versions in config like I have implemented here https://github.com/humhub/humhub/pull/5648, the versions are hardcoded currently in the protected/humhub/libs/SelfTest.php:

php-version

yurabakhtin commented 2 years ago

@luke- Also here https://github.com/humhub/updater/blob/master/controllers/UpdateController.php#L53 we have a hardcoded php version:

if (version_compare(phpversion(), '5.6', '<')) {

I think it would be better to use it from new config var Yii::$app->minSupportedPhpVersion, of course it will works only for current/old HumHub version and not for new downloaded HumHub version.

yurabakhtin commented 2 years ago

@luke- I have implemented the checking PHP version on update by getting value from new HumHub config minSupportedPhpVersion what I added in the new PR https://github.com/humhub/humhub/pull/5648/files#diff-a3c6d173ee0bb6143169e09f50556d13b5bc5ebd29b444d9346e7ffaa3d186c8R29, if the updated package still has no the new config minSupportedPhpVersion then the PHP checking just will be skipped.

It will be works like this: check_php_on_update

PR https://github.com/humhub/updater/pull/30.


If here https://docs.humhub.org/docs/admin/requirements/#php-environment we removed the supporting PHP 7.3 for version 1.11 so I have done this update - https://github.com/humhub/humhub/pull/5648/commits/c21a963b5b6e6b3b3665f5c5d619466f5b79c470#diff-a3c6d173ee0bb6143169e09f50556d13b5bc5ebd29b444d9346e7ffaa3d186c8R29, i.e. for version 1.11 both new configs minRecommendedPhpVersion and minSupportedPhpVersion should be set to 7.4.

For version 1.10 we can keep them as 7.4 and 7.3, please let me know if there I should add them in master branch.

luke- commented 2 years ago

@yurabakhtin Thanks!