From f94aef3d89bdde4cbe04c24a5c10c6f63c8c6fb7 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Fri, 12 Apr 2013 07:06:41 +0000 Subject: [PATCH] Fixes #3877, add warning message that is displayed if a user's PHP version is less than 5.3. --- core/Controller/Admin.php | 12 ++++++++++++ lang/en.php | 3 +++ plugins/CoreAdminHome/templates/header.tpl | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/core/Controller/Admin.php b/core/Controller/Admin.php index 2378d005d0f..a2b1cbffcbc 100644 --- a/core/Controller/Admin.php +++ b/core/Controller/Admin.php @@ -61,5 +61,17 @@ static public function setBasicVariablesAdminView($view) '' )); } + + self::checkPhpVersion($view); + } + + /** + * 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', '>='); } } diff --git a/lang/en.php b/lang/en.php index 4c16af9b169..bdba2286c3e 100644 --- a/lang/en.php +++ b/lang/en.php @@ -521,6 +521,9 @@ 'CoreAdminHome_StableReleases' => 'If Piwik is a critical part of your business, we recommend you use the latest stable release. If you use the latest beta and you find a bug or have a suggestion, please %ssee here%s.', + 'CoreAdminHome_YouAreCurrentlyUsingPHP' => 'You are currently using PHP %1$s.', + 'CoreAdminHome_OldPHPVersionWarning_Part1' => 'Piwik is quickly improving and in order to provide you with an improved state-of-the-art Web Analytics platform, we will soon be increasing the minimum required PHP version to PHP 5.3. %1$sPlease ask your server administrator or web hosting provider to update your PHP to the latest version, ideally PHP 5.4.%2$s', + 'CoreAdminHome_OldPHPVersionWarning_Part2' => 'When you upgrade to PHP 5.3 or higher, this message will disappear and your Piwik server will process reports much faster using less memory. %1$sUpdate PHP and get the most out of Piwik!%2$s', 'CoreHome_InjectedHostWarningIntro' => 'You are now accessing Piwik from %1$s, but Piwik has been configured to run at this address: %2$s.', 'CoreHome_InjectedHostSuperUserWarning' => 'Piwik may be misconfigured (for example, if Piwik was recently moved to a new server or URL). You can either %1$sclick here and add %2$s as the valid Piwik hostname (if you trust it)%3$s, or %4$sclick here and go to %5$s to access Piwik safely%6$s.', 'CoreHome_InjectedHostNonSuperUserWarning' => '%1$sClick here to access Piwik safely%2$s and remove this warning. You may also want to contact your Piwik administrator and notify them about this issue (%3$sclick here to email%4$s).', diff --git a/plugins/CoreAdminHome/templates/header.tpl b/plugins/CoreAdminHome/templates/header.tpl index 84a8407b0a5..fd91d9b425a 100644 --- a/plugins/CoreAdminHome/templates/header.tpl +++ b/plugins/CoreAdminHome/templates/header.tpl @@ -66,6 +66,17 @@ {include file="CoreHome/templates/warning_invalid_host.tpl"} + + {* PHP version < 5.3 warning *} + {if empty($phpIsNewEnough)} +
+ {'CoreAdminHome_YouAreCurrentlyUsingPHP'|translate:$phpVersion} +

+ {'CoreAdminHome_OldPHPVersionWarning_Part1'|translate:'':''} +

+ {'CoreAdminHome_OldPHPVersionWarning_Part2'|translate:'':''} +
+ {/if} {* missing plugins warning *} {if $isSuperUser && !empty($missingPluginsWarning)}