Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Aubry <mattab@users.noreply.github.com>2016-10-02 23:29:34 +0300
committerGitHub <noreply@github.com>2016-10-02 23:29:34 +0300
commite692a36e11c65f9f302b650b67e859a4ded64ebe (patch)
treed721223ea9007a7de7031c99707bc1a6be7bffe0
parent6972f4328852c3b96f63e353964b59bdfd7d6dc3 (diff)
parentcdd380b519de005035fc2f7122a0f2427672f3c2 (diff)
Merge pull request #10633 from piwik/notify_users_when_php_needs_upgrade_to_use_latest_major
Warn users (in all admin pages) when the PHP version is not recent enough to upgrade Piwik to latest major version
-rw-r--r--core/Plugin/ControllerAdmin.php54
-rw-r--r--lang/en.json3
2 files changed, 41 insertions, 16 deletions
diff --git a/core/Plugin/ControllerAdmin.php b/core/Plugin/ControllerAdmin.php
index e503a615e6..f24246944f 100644
--- a/core/Plugin/ControllerAdmin.php
+++ b/core/Plugin/ControllerAdmin.php
@@ -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('PHPVersionTooOldForNewestPiwikCheck', $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;
diff --git a/lang/en.json b/lang/en.json
index a9856cc425..bbe45c2a77 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -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.",