Skip to content
Extraits de code Groupes Projets
Valider 75871fcb rédigé par mattab's avatar mattab
Parcourir les fichiers

Warn users (in all admin pages) when the PHP version is not recent enough to...

Warn users (in all admin pages) when the PHP version is not recent enough to upgrade Piwik to latest major version
parent f42860f4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -153,6 +153,42 @@ abstract class ControllerAdmin extends Controller
Notification\Manager::notify('ControllerAdmin_EacceleratorIsUsed', $notification);
}
/**
* PHP Version required by the next major Piwik version
* @return string
*/
private static function getNextRequiredMinimumPHP()
{
return '5.5.9';
}
private static function isUsingPhpVersionCompatibleWithNextPiwik()
{
return version_compare( PHP_VERSION, self::getNextRequiredMinimumPHP(), '>=' );
}
private static function notifyWhenPhpVersionIsNotCompatibleWithNextMajorPiwik()
{
if(self::isUsingPhpVersionCompatibleWithNextPiwik()) {
return;
}
$youMustUpgradePHP = Piwik::translate('General_YouMustUpgradePhpVersionToReceiveLatestPiwik');
$message = Piwik::translate('General_PiwikCannotBeUpgradedBecausePhpIsTooOld')
. ' '
. sprintf(Piwik::translate('General_PleaseUpgradeYourPhpVersionSoYourPiwikDataStaysSecure'), self::getNextRequiredMinimumPHP())
;
$notification = new Notification($message);
$notification->title = $youMustUpgradePHP;
$notification->priority = Notification::PRIORITY_LOW;
$notification->context = Notification::CONTEXT_WARNING;
$notification->type = Notification::TYPE_TRANSIENT;
$notification->flags = Notification::FLAG_NO_CLEAR;
NotificationManager::notify('DeprecatedPHPVersionCheck', $notification);
}
private static function notifyWhenPhpVersionIsEOL()
{
$deprecatedMajorPhpVersion = null;
......@@ -167,9 +203,7 @@ abstract class ControllerAdmin extends Controller
return;
}
$nextRequiredMinimumPHP = '5.5';
$message = Piwik::translate('General_WarningPiwikWillStopSupportingPHPVersion', array($deprecatedMajorPhpVersion, $nextRequiredMinimumPHP))
$message = Piwik::translate('General_WarningPiwikWillStopSupportingPHPVersion', array($deprecatedMajorPhpVersion, self::getNextRequiredMinimumPHP()))
. "\n "
. Piwik::translate('General_WarningPhpVersionXIsTooOld', $deprecatedMajorPhpVersion);
......@@ -243,10 +277,8 @@ abstract class ControllerAdmin extends Controller
$view->isSuperUser = Piwik::hasUserSuperUserAccess();
self::notifyAnyInvalidPlugin();
self::checkPhpVersion($view);
self::notifyWhenPhpVersionIsEOL();
self::notifyWhenPhpVersionIsNotCompatibleWithNextMajorPiwik();
self::notifyWhenDebugOnDemandIsEnabled('debug');
self::notifyWhenDebugOnDemandIsEnabled('debug_on_demand');
......@@ -271,16 +303,6 @@ abstract class ControllerAdmin extends Controller
return "Piwik " . Version::VERSION;
}
/**
* Check if the current PHP version is >= 5.3. If not, a warning is displayed
* to the user.
*/
private static function checkPhpVersion($view)
{
$view->phpVersion = PHP_VERSION;
$view->phpIsNewEnough = version_compare($view->phpVersion, '5.3.0', '>=');
}
private static function isPhpVersion53()
{
return strpos(PHP_VERSION, '5.3') === 0;
......
......@@ -395,6 +395,9 @@
"Warning": "Warning",
"WarningPhpVersionXIsTooOld": "The PHP version %s you are using has reached its End of Life (EOL). You are strongly urged to upgrade to a current version, as using this version may expose you to security vulnerabilities and bugs that have been fixed in more recent versions of PHP.",
"WarningPiwikWillStopSupportingPHPVersion": "Piwik will stop supporting PHP %1$s in the next major version. Upgrade your PHP to at least PHP %2$s, before it's too late!",
"YouMustUpgradePhpVersionToReceiveLatestPiwik": "You must upgrade your PHP version in order to receive the latest Piwik update.",
"PiwikCannotBeUpgradedBecausePhpIsTooOld": "Piwik cannot be upgraded to the latest major version because your PHP version is too old.",
"PleaseUpgradeYourPhpVersionSoYourPiwikDataStaysSecure": "Please upgrade your PHP version to at least PHP %s so your Piwik analytics data stays secure.",
"WarningFileIntegrityNoManifest": "File integrity check could not be performed due to missing manifest.inc.php.",
"WarningFileIntegrityNoManifestDeployingFromGit": "If you are deploying Piwik from Git, this message is normal.",
"WarningFileIntegrityNoMd5file": "File integrity check could not be completed due to missing md5_file() function.",
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter