diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2016-09-30 02:03:13 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2016-09-30 02:03:13 +0300 |
commit | 43bd151e711d5c719cf89d2746c23da5e29dd264 (patch) | |
tree | af3c4969a64f759811a08c026b739b3d8e716435 /core/Plugin/ControllerAdmin.php | |
parent | 68fea796ef5a81cf7c5f4fb17508968ac898bb7c (diff) | |
parent | 7d115b50ecb1660175e64e4e546c72546fd56d69 (diff) |
Merge branch '2.x-dev' into 3.0-m09
Diffstat (limited to 'core/Plugin/ControllerAdmin.php')
-rw-r--r-- | core/Plugin/ControllerAdmin.php | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/core/Plugin/ControllerAdmin.php b/core/Plugin/ControllerAdmin.php index 89fc082199..092a963b8a 100644 --- a/core/Plugin/ControllerAdmin.php +++ b/core/Plugin/ControllerAdmin.php @@ -155,6 +155,43 @@ 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() + { + return; // no major version coming + + 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('PHPVersionTooOldForNewestPiwikCheck', $notification); + } + private static function notifyWhenPhpVersionIsEOL() { return; // no supported version (5.5+) has currently ended support @@ -163,7 +200,10 @@ abstract class ControllerAdmin extends Controller return; } - $message = Piwik::translate('General_WarningPhpVersionXIsTooOld', '5.5'); + $message = Piwik::translate('General_WarningPiwikWillStopSupportingPHPVersion', array($deprecatedMajorPhpVersion, self::getNextRequiredMinimumPHP())) + . "\n " + . Piwik::translate('General_WarningPhpVersionXIsTooOld', $deprecatedMajorPhpVersion); + $notification = new Notification($message); $notification->title = Piwik::translate('General_Warning'); $notification->priority = Notification::PRIORITY_LOW; @@ -233,10 +273,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'); @@ -260,16 +298,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 = self::isPhpVersionAtLeast55(); - } - private static function isPhpVersionAtLeast55() { return version_compare(PHP_VERSION, '5.5', '>='); |