mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-10275 moved the rest of environment tests from install.php to admin/index.php; please note that there is no need to update installer lacg packs becuase install.php will not have environment checks anymore soon ;-)
This commit is contained in:
parent
a825fec763
commit
c808379ef8
@ -270,13 +270,30 @@
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/customcheckslib.php" function="php_check_register_globals" level="required">
|
||||
<PHP_EXTENSION name="gd" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="globalswarning" />
|
||||
<ON_CHECK message="gdrecommended" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="40M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
@ -378,6 +378,9 @@ $string['enrolmultipleusers'] = 'Enrol the users';
|
||||
$string['environment'] = 'Environment';
|
||||
$string['environmenterrortodo'] = 'You must solve all the environmental problems (errors) found above before proceeding to install this Moodle version!';
|
||||
$string['environmenterrorupgrade'] = 'Warning: you should solve all the environmental problems (errors) found above before proceeding to upgrade this Moodle version! Upgrading without fixing these requirements could cause problems such as data loss. Are you sure you want to continue with the upgrade?';
|
||||
$string['environmenmustfixsetting'] = 'PHP setting must be changed.';
|
||||
$string['environmenshouldfixsetting'] = 'PHP setting should be changed.';
|
||||
$string['environmentsettingok'] = 'Recommended setting detected';
|
||||
$string['environmentok'] = 'Your server environment meets all minimum requirements.';
|
||||
$string['environmentrecommendcustomcheck'] = 'if this test fails, it indicates a potential problem';
|
||||
$string['environmentrecommendinstall'] = 'should be installed and enabled for best results';
|
||||
@ -421,6 +424,7 @@ $string['frontpagerestore'] = 'Front Page restore';
|
||||
$string['frontpageroles'] = 'Front Page roles';
|
||||
$string['frontpagesettings'] = 'Front Page settings';
|
||||
$string['fullnamedisplay'] = 'Full Name Format';
|
||||
$string['gdrecommended'] = 'GD extension is used for conversion of images, some features such as user progile images will not be available if missing.';
|
||||
$string['gdversion'] = 'GD version';
|
||||
$string['generalsettings'] = 'General settings';
|
||||
$string['geoipfile'] = 'GeoIP City data file';
|
||||
@ -723,6 +727,9 @@ $string['sessioncookiedomain'] = 'Cookie domain';
|
||||
$string['sessioncookiepath'] = 'Cookie path';
|
||||
$string['sessionhandling'] = 'Session Handling';
|
||||
$string['sessiontimeout'] = 'Timeout';
|
||||
$string['settingsafemode'] = 'Moodle is not fully compatible with safe mode, please ask server administrator to turn it off. Running Moodle under safe mode is not supported, please expect various problems if you do so.';
|
||||
$string['settingfileuploads'] = 'File uploading is required for normal operation, please neable it in PHP configuration.';
|
||||
$string['settingmemorylimit'] = 'Insufficient memory detected, please set higher memory limit in PHP settings.';
|
||||
$string['showblocksonmodpages'] = 'Show blocks on module pages';
|
||||
$string['showdetails'] = 'Show details';
|
||||
$string['simpletest'] = 'Unit tests';
|
||||
|
@ -50,6 +50,7 @@
|
||||
define('NO_CUSTOM_CHECK_FOUND', 12);
|
||||
define('CUSTOM_CHECK_FILE_MISSING', 13);
|
||||
define('CUSTOM_CHECK_FUNCTION_MISSING', 14);
|
||||
define('NO_PHP_SETTINGS_NAME_FOUND', 15);
|
||||
|
||||
/**
|
||||
* This function will perform the whole check, returning
|
||||
@ -111,7 +112,6 @@ function check_moodle_environment($version, &$environment_results, $print_table=
|
||||
if ($print_table) {
|
||||
print_moodle_environment($result && $status, $environment_results);
|
||||
}
|
||||
|
||||
return ($result && $status);
|
||||
}
|
||||
|
||||
@ -194,6 +194,14 @@ function print_moodle_environment($result, $environment_results) {
|
||||
} else {
|
||||
$stringtouse = 'environmentrecommendcustomcheck';
|
||||
}
|
||||
} else if ($environment_result->getPart() == 'php_setting') {
|
||||
if ($status) {
|
||||
$stringtouse = 'environmentsettingok';
|
||||
} else if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmenmustfixsetting';
|
||||
} else {
|
||||
$stringtouse = 'environmenshouldfixsetting';
|
||||
}
|
||||
} else {
|
||||
if ($environment_result->getLevel() == 'required') {
|
||||
$stringtouse = 'environmentrequireinstall';
|
||||
@ -455,6 +463,9 @@ function environment_check($version) {
|
||||
$phpext_results = environment_check_php_extensions($version);
|
||||
$results = array_merge($results, $phpext_results);
|
||||
|
||||
$phpsetting_results = environment_check_php_settings($version);
|
||||
$results = array_merge($results, $phpsetting_results);
|
||||
|
||||
$custom_results = environment_custom_checks($version);
|
||||
$results = array_merge($results, $custom_results);
|
||||
|
||||
@ -520,6 +531,81 @@ function environment_check_php_extensions($version) {
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will check if php extensions requirements are satisfied
|
||||
* @param string $version xml version we are going to use to test this server
|
||||
* @return array array of results encapsulated in one environment_result object
|
||||
*/
|
||||
function environment_check_php_settings($version) {
|
||||
|
||||
$results = array();
|
||||
|
||||
/// Get the enviroment version we need
|
||||
if (!$data = get_environment_for_version($version)) {
|
||||
/// Error. No version data found
|
||||
$result = new environment_results('php_setting');
|
||||
$result->setStatus(false);
|
||||
$result->setErrorCode(NO_VERSION_DATA_FOUND);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/// Extract the php_setting part
|
||||
if (!isset($data['#']['PHP_SETTINGS']['0']['#']['PHP_SETTING'])) {
|
||||
/// No PHP section found - ignore
|
||||
return $results;
|
||||
}
|
||||
/// Iterate over settings checking them and creating the needed environment_results
|
||||
foreach($data['#']['PHP_SETTINGS']['0']['#']['PHP_SETTING'] as $setting) {
|
||||
$result = new environment_results('php_setting');
|
||||
/// Check for level
|
||||
$level = get_level($setting);
|
||||
$result->setLevel($level);
|
||||
/// Check for extension name
|
||||
if (!isset($setting['@']['name'])) {
|
||||
$result->setStatus(false);
|
||||
$result->setErrorCode(NO_PHP_SETTINGS_NAME_FOUND);
|
||||
} else {
|
||||
$setting_name = $setting['@']['name'];
|
||||
$setting_value = $setting['@']['value'];
|
||||
$result->setInfo($setting_name);
|
||||
|
||||
if ($setting_name == 'memory_limit') {
|
||||
$current = ini_get('memory_limit');
|
||||
if ($current == -1) {
|
||||
$result->setStatus(true);
|
||||
} else {
|
||||
$current = get_real_size($current);
|
||||
$minlimit = get_real_size($setting_value);
|
||||
if ($current < $minlimit) {
|
||||
@ini_set('memory_limit', $setting_value);
|
||||
$current = ini_get('memory_limit');
|
||||
$current = get_real_size($current);
|
||||
}
|
||||
$result->setStatus($current >= $minlimit);
|
||||
}
|
||||
|
||||
} else {
|
||||
$current = ini_get_bool($setting_name);
|
||||
/// The name exists. Just check if it's an installed extension
|
||||
if ($current == $setting_value) {
|
||||
$result->setStatus(true);
|
||||
} else {
|
||||
$result->setStatus(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Do any actions defined in the XML file.
|
||||
process_environment_result($setting, $result);
|
||||
|
||||
/// Add the result to the array of results
|
||||
$results[] = $result;
|
||||
}
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will do the custom checks.
|
||||
* @param string $version xml version we are going to use to test this server.
|
||||
@ -947,7 +1033,7 @@ function process_environment_messages($xml, &$result) {
|
||||
*/
|
||||
class environment_results {
|
||||
|
||||
var $part; //which are we checking (database, php, php_extension)
|
||||
var $part; //which are we checking (database, php, php_extension, php_extension)
|
||||
var $status; //true/false
|
||||
var $error_code; //integer. See constants at the beginning of the file
|
||||
var $level; //required/optional
|
||||
|
Loading…
x
Reference in New Issue
Block a user