Prevent upgrade of Grav if PHP min requirement is not met. Gracefully fail with additional information

This commit is contained in:
Djamil Legato
2015-12-18 13:42:57 -08:00
parent 688d488218
commit fbe778dbae
2 changed files with 12 additions and 1 deletions

View File

@@ -862,7 +862,7 @@ class AdminController
require_once __DIR__ . '/gpm.php'; require_once __DIR__ . '/gpm.php';
if (!$this->authorizeTask('install grav', ['admin.super'])) { if (!$this->authorizeTask('install grav', ['admin.super'])) {
return; return false;
} }
$result = \Grav\Plugin\Admin\Gpm::selfupgrade(); $result = \Grav\Plugin\Admin\Gpm::selfupgrade();

View File

@@ -179,6 +179,17 @@ class Gpm
return false; return false;
} }
if (!$upgrader->meetsRequirements()) {
$error = [];
$error[] = '<p>Grav has increased the minimum PHP requirement.<br />';
$error[] = 'You are currently running PHP <strong>' . PHP_VERSION .'</strong>';
$error[] = ', but PHP <strong>' . GRAV_PHP_MIN .'</strong> is required.</p>';
$error[] = '<p><a href="http://getgrav.org/blog/changing-php-requirements-to-5.5" class="button button-small secondary">Additional information</a></p>';
Installer::setError(implode("\n", $error));
return false;
}
$update = $upgrader->getAssets()['grav-update']; $update = $upgrader->getAssets()['grav-update'];
$tmp = CACHE_DIR . 'tmp/Grav-' . uniqid(); $tmp = CACHE_DIR . 'tmp/Grav-' . uniqid();
$file = self::_downloadSelfupgrade($update, $tmp); $file = self::_downloadSelfupgrade($update, $tmp);