diff --git a/admin/environment.xml b/admin/environment.xml index cd178186805..4b9f4568d63 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -577,6 +577,11 @@ + + + + + @@ -670,5 +675,5 @@ - + diff --git a/lang/en/admin.php b/lang/en/admin.php index b19619988c3..321690773c8 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -741,6 +741,7 @@ $string['pathtopsqldesc'] = 'This is only necessary to enter if you have more th $string['pathtopsqlinvalid'] = 'Invalid path to psql - either wrong path or not executable'; $string['pathtounzip'] = 'Path to unzip'; $string['pathtozip'] = 'Path to zip'; +$string['pcreunicodewarning'] = 'It is strongly recommended to use PCRE PHP extension that is compatible with Unicode characters.'; $string['perfdebug'] = 'Performance info'; $string['performance'] = 'Performance'; $string['pgcluster'] = 'PostgreSQL Cluster'; diff --git a/lib/environmentlib.php b/lib/environmentlib.php index 607bcfb76b0..be7aabf68a7 100644 --- a/lib/environmentlib.php +++ b/lib/environmentlib.php @@ -438,6 +438,10 @@ function environment_check($version, $env_select) { $results[] = environment_check_database($version, $env_select); $results[] = environment_check_php($version, $env_select); + if ($result = environment_check_pcre_unicode($version, $env_select)) { + $results[] = $result; + } + $phpext_results = environment_check_php_extensions($version, $env_select); $results = array_merge($results, $phpext_results); @@ -794,6 +798,46 @@ function environment_check_php($version, $env_select) { return $result; } +/** + * Looks for buggy PCRE implementation, we need unicode support in Moodle... + * @param string $version xml version we are going to use to test this server + * @param int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. + * @return stdClass results encapsulated in one environment_result object, null if irrelevant + */ +function environment_check_pcre_unicode($version, $env_select) { + $result = new environment_results('pcreunicode'); + + // Get the environment version we need + if (!$data = get_environment_for_version($version, $env_select)) { + // Error. No version data found! + $result->setStatus(false); + $result->setErrorCode(NO_VERSION_DATA_FOUND); + return $result; + } + + if (!isset($data['#']['PCREUNICODE'])) { + return null; + } + + $level = get_level($data['#']['PCREUNICODE']['0']); + $result->setLevel($level); + + if (!function_exists('preg_match')) { + // The extension test fails instead. + return null; + + } else if (@preg_match('/\pL/u', 'a') and @preg_match('/á/iu', 'Á')) { + $result->setStatus(true); + + } else { + $result->setStatus(false); + } + + // Do any actions defined in the XML file. + process_environment_result($data['#']['PCREUNICODE'][0], $result); + + return $result; +} /** * This function will check if unicode database requirements are satisfied