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

Fixes #6468 Error in system check when always_populate_raw_post_data is not -1 on PHP 5.6+

parent 315b6fea
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -635,30 +635,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin ...@@ -635,30 +635,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
{ {
$view->infos = self::getSystemInformation(); $view->infos = self::getSystemInformation();
$view->helpMessages = array( $view->helpMessages = $this->getSystemCheckHelpMessages();
'zlib' => 'Installation_SystemCheckZlibHelp',
'gzopen' => 'Installation_SystemCheckZlibHelp',
'SPL' => 'Installation_SystemCheckSplHelp',
'iconv' => 'Installation_SystemCheckIconvHelp',
'mbstring' => 'Installation_SystemCheckMbstringHelp',
'Reflection' => 'Required extension that is built in PHP, see http://www.php.net/manual/en/book.reflection.php',
'json' => 'Installation_SystemCheckWarnJsonHelp',
'libxml' => 'Installation_SystemCheckWarnLibXmlHelp',
'dom' => 'Installation_SystemCheckWarnDomHelp',
'SimpleXML' => 'Installation_SystemCheckWarnSimpleXMLHelp',
'set_time_limit' => 'Installation_SystemCheckTimeLimitHelp',
'mail' => 'Installation_SystemCheckMailHelp',
'parse_ini_file' => 'Installation_SystemCheckParseIniFileHelp',
'glob' => 'Installation_SystemCheckGlobHelp',
'debug_backtrace' => 'Installation_SystemCheckDebugBacktraceHelp',
'create_function' => 'Installation_SystemCheckCreateFunctionHelp',
'eval' => 'Installation_SystemCheckEvalHelp',
'gzcompress' => 'Installation_SystemCheckGzcompressHelp',
'gzuncompress' => 'Installation_SystemCheckGzuncompressHelp',
'pack' => 'Installation_SystemCheckPackHelp',
'php5-json' => 'Installation_SystemCheckJsonHelp',
'session.auto_start' => 'Installation_SystemCheckSessionAutostart',
);
$view->problemWithSomeDirectories = (false !== array_search(false, $view->infos['directories'])); $view->problemWithSomeDirectories = (false !== array_search(false, $view->infos['directories']));
} }
...@@ -746,4 +723,44 @@ class Controller extends \Piwik\Plugin\ControllerAdmin ...@@ -746,4 +723,44 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
return $result; return $result;
}); });
} }
/**
* @return array
*/
private function getSystemCheckHelpMessages()
{
$helpMessages = array(
// Extensions
'zlib' => 'Installation_SystemCheckZlibHelp',
'gzopen' => 'Installation_SystemCheckZlibHelp',
'SPL' => 'Installation_SystemCheckSplHelp',
'iconv' => 'Installation_SystemCheckIconvHelp',
'mbstring' => 'Installation_SystemCheckMbstringHelp',
'Reflection' => 'Required extension that is built in PHP, see http://www.php.net/manual/en/book.reflection.php',
'json' => 'Installation_SystemCheckWarnJsonHelp',
'libxml' => 'Installation_SystemCheckWarnLibXmlHelp',
'dom' => 'Installation_SystemCheckWarnDomHelp',
'SimpleXML' => 'Installation_SystemCheckWarnSimpleXMLHelp',
// Functions
'set_time_limit' => 'Installation_SystemCheckTimeLimitHelp',
'mail' => 'Installation_SystemCheckMailHelp',
'parse_ini_file' => 'Installation_SystemCheckParseIniFileHelp',
'glob' => 'Installation_SystemCheckGlobHelp',
'debug_backtrace' => 'Installation_SystemCheckDebugBacktraceHelp',
'create_function' => 'Installation_SystemCheckCreateFunctionHelp',
'eval' => 'Installation_SystemCheckEvalHelp',
'gzcompress' => 'Installation_SystemCheckGzcompressHelp',
'gzuncompress' => 'Installation_SystemCheckGzuncompressHelp',
'pack' => 'Installation_SystemCheckPackHelp',
'php5-json' => 'Installation_SystemCheckJsonHelp',
);
// Add standard message for required PHP.ini settings
$requiredSettings = SystemCheck::getRequiredPhpSettings();
foreach($requiredSettings as $requiredSetting) {
$helpMessages[$requiredSetting] = Piwik::translate('Installation_SystemCheckPhpSetting', $requiredSetting);
}
return $helpMessages;
}
} }
...@@ -55,13 +55,11 @@ class SystemCheck ...@@ -55,13 +55,11 @@ class SystemCheck
$infos['desired_extensions'] = self::getRecommendedExtensions(); $infos['desired_extensions'] = self::getRecommendedExtensions();
$infos['missing_desired_extensions'] = self::getRecommendedExtensionsMissing(); $infos['missing_desired_extensions'] = self::getRecommendedExtensionsMissing();
$infos['desired_functions'] = self::getRecommendedFunctions();
$infos['missing_desired_functions'] = self::getRecommendedFunctionsMissing(); $infos['missing_desired_functions'] = self::getRecommendedFunctionsMissing();
//TODO create recommended settings $infos['needed_settings'] = self::getRequiredPhpSettings();
$desired_settings = array( $infos['missing_settings'] = self::getMissingPhpSettings();
'session.auto_start',
);
$infos['desired_functions'] = array_merge(self::getRecommendedFunctions(), $desired_settings);
$infos['openurl'] = Http::getTransportMethod(); $infos['openurl'] = Http::getTransportMethod();
$infos['gd_ok'] = SettingsServer::isGdExtensionEnabled(); $infos['gd_ok'] = SettingsServer::isGdExtensionEnabled();
...@@ -159,7 +157,6 @@ class SystemCheck ...@@ -159,7 +157,6 @@ class SystemCheck
if (!DbHelper::isInstalled()) { if (!DbHelper::isInstalled()) {
// at install, need /config to be writable (so we can create config.ini.php) // at install, need /config to be writable (so we can create config.ini.php)
$directoriesToCheck[] = '/config/'; $directoriesToCheck[] = '/config/';
return $directoriesToCheck;
} }
return $directoriesToCheck; return $directoriesToCheck;
} }
...@@ -169,7 +166,7 @@ class SystemCheck ...@@ -169,7 +166,7 @@ class SystemCheck
*/ */
protected static function getRequiredFunctions() protected static function getRequiredFunctions()
{ {
return $needed_functions = array( return array(
'debug_backtrace', 'debug_backtrace',
'create_function', 'create_function',
'eval', 'eval',
...@@ -372,9 +369,9 @@ class SystemCheck ...@@ -372,9 +369,9 @@ class SystemCheck
protected static function getRequiredExtensionsMissing() protected static function getRequiredExtensionsMissing()
{ {
$missingExtensions = array(); $missingExtensions = array();
foreach (self::getRequiredExtensions() as $needed_extension) { foreach (self::getRequiredExtensions() as $requiredExtension) {
if (!self::isPhpExtensionLoaded($needed_extension)) { if (!self::isPhpExtensionLoaded($requiredExtension)) {
$missingExtensions[] = $needed_extension; $missingExtensions[] = $requiredExtension;
} }
} }
...@@ -400,14 +397,7 @@ class SystemCheck ...@@ -400,14 +397,7 @@ class SystemCheck
*/ */
protected static function getRecommendedFunctionsMissing() protected static function getRecommendedFunctionsMissing()
{ {
$recommendedFunctionsMissing = self::getFunctionsMissing(self::getRecommendedFunctions()); return self::getFunctionsMissing(self::getRecommendedFunctions());
$sessionAutoStarted = (int)ini_get('session.auto_start');
if ($sessionAutoStarted) {
$recommendedFunctionsMissing[] = 'session.auto_start';
}
return $recommendedFunctionsMissing;
} }
/** /**
...@@ -437,5 +427,45 @@ class SystemCheck ...@@ -437,5 +427,45 @@ class SystemCheck
return Config::getInstance()->General['minimum_memory_limit']; return Config::getInstance()->General['minimum_memory_limit'];
} }
private static function isPhpVersionAtLeast56()
{
return version_compare( PHP_VERSION, '5.6', '>=');
}
/**
* @return array
*/
public static function getRequiredPhpSettings()
{
$requiredPhpSettings = array(
// setting = required value
// Note: value must be an integer only
'session.auto_start=0',
);
if (self::isPhpVersionAtLeast56()) {
// always_populate_raw_post_data must be -1
$requiredPhpSettings[] = 'always_populate_raw_post_data=-1';
}
return $requiredPhpSettings;
}
/**
* @return array
*/
protected static function getMissingPhpSettings()
{
$missingPhpSettings = array();
foreach(self::getRequiredPhpSettings() as $requiredSetting) {
list($requiredSettingName, $requiredSettingValue) = explode('=', $requiredSetting);
$currentValue = ini_get($requiredSettingName);
$currentValue = (int)$currentValue;
if($currentValue != $requiredSettingValue) {
$missingPhpSettings[] = $requiredSetting;
}
}
return $missingPhpSettings;
}
} }
\ No newline at end of file
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
"SystemCheckPhp": "PHP version", "SystemCheckPhp": "PHP version",
"SystemCheckPhpPdoAndMysqli": "More information on: %1$sPHP PDO%2$s and %3$sMYSQLI%4$s.", "SystemCheckPhpPdoAndMysqli": "More information on: %1$sPHP PDO%2$s and %3$sMYSQLI%4$s.",
"SystemCheckSplHelp": "You need to configure and rebuild PHP with the Standard PHP Library (SPL) enabled (by default).", "SystemCheckSplHelp": "You need to configure and rebuild PHP with the Standard PHP Library (SPL) enabled (by default).",
"SystemCheckSettings": "Required PHP configuration (php.ini)",
"SystemCheckSummaryNoProblems": "Huzzah! There are no problems with your Piwik setup. Give yourself a pat on the back.", "SystemCheckSummaryNoProblems": "Huzzah! There are no problems with your Piwik setup. Give yourself a pat on the back.",
"SystemCheckSummaryThereWereErrors": "Uh-oh! Piwik has detected some %1$scritical issues%2$s with your Piwik setup. %3$sThese issues should be fixed immediately.%4$s", "SystemCheckSummaryThereWereErrors": "Uh-oh! Piwik has detected some %1$scritical issues%2$s with your Piwik setup. %3$sThese issues should be fixed immediately.%4$s",
"SystemCheckSummaryThereWereWarnings": "There are some issues with your system. Piwik will run, but you might experience some minor problems.", "SystemCheckSummaryThereWereWarnings": "There are some issues with your system. Piwik will run, but you might experience some minor problems.",
...@@ -112,7 +113,7 @@ ...@@ -112,7 +113,7 @@
"SystemCheckZlibHelp": "You need to configure and rebuild PHP with \"zlib\" support enabled, --with-zlib.", "SystemCheckZlibHelp": "You need to configure and rebuild PHP with \"zlib\" support enabled, --with-zlib.",
"SystemCheckCronArchiveProcess": "Archive Cron", "SystemCheckCronArchiveProcess": "Archive Cron",
"SystemCheckCronArchiveProcessCLI": "Managing processes via CLI", "SystemCheckCronArchiveProcessCLI": "Managing processes via CLI",
"SystemCheckSessionAutostart": "To prevent some issues please set the following in your php.ini file: session.auto_start=0", "SystemCheckPhpSetting": "To prevent some critical issue, you must set the following in your php.ini file: %s",
"NotSupported": "not supported", "NotSupported": "not supported",
"Tables": "Creating the Tables", "Tables": "Creating the Tables",
"TablesCreatedSuccess": "Tables created with success!", "TablesCreatedSuccess": "Tables created with success!",
......
...@@ -56,14 +56,13 @@ ...@@ -56,14 +56,13 @@
{% for needed_extension in infos.needed_extensions %} {% for needed_extension in infos.needed_extensions %}
{% if needed_extension in infos.missing_extensions %} {% if needed_extension in infos.missing_extensions %}
{{ error }} {{ error }}
{% set hasError %}1{% endset %} <br/>{{ 'Installation_RestartWebServer'|translate }}
{% else %} {% else %}
{{ ok }} {{ ok }}
{% endif %} {% endif %}
{{ needed_extension }} {{ needed_extension }}
<br/> <br/>
{% endfor %} {% endfor %}
<br/>{% if hasError is defined %}{{ 'Installation_RestartWebServer'|translate }}{% endif %}
</td> </td>
</tr> </tr>
{% if infos.missing_extensions|length > 0 %} {% if infos.missing_extensions|length > 0 %}
...@@ -84,16 +83,37 @@ ...@@ -84,16 +83,37 @@
{% if needed_function in infos.missing_functions %} {% if needed_function in infos.missing_functions %}
{{ error }} {{ error }}
<span class='err'>{{ needed_function }}</span> <span class='err'>{{ needed_function }}</span>
{% set hasError %}1{% endset %}
<p> <p>
<em>{{ helpMessages[needed_function]|translate }}</em> <em>
{{ helpMessages[needed_function]|translate }}
<br/>{{ 'Installation_RestartWebServer'|translate }}
</em>
</p> </p>
{% else %} {% else %}
{{ ok }} {{ needed_function }} {{ ok }} {{ needed_function }}
<br/> <br/>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<br/>{% if hasError is defined %}{{ 'Installation_RestartWebServer'|translate }}{% endif %} </td>
</tr>
<tr>
<td class="label">{{ 'Installation_SystemCheckSettings'|translate }}</td>
<td>
{% for needed_setting in infos.needed_settings %}
{% if needed_setting in infos.missing_settings %}
{{ error }}
<span class='err'>{{ needed_setting }}</span>
<p>
<em>
{{ helpMessages[needed_setting]|translate }}
<br/>{{ 'Installation_RestartWebServer'|translate }}
</em>
</p>
{% else %}
{{ ok }} {{ needed_setting }}
<br/>
{% endif %}
{% endfor %}
</td> </td>
</tr> </tr>
<tr> <tr>
......
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