mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-60943 core_search: Improve exception for preg_replace errors
This commit is contained in:
parent
013f0b2266
commit
d20ec3606b
@ -52,6 +52,7 @@ $string['enginenotinstalled'] = 'Engine {$a} is not installed.';
|
||||
$string['enginenotselected'] = 'You have not selected any search engine.';
|
||||
$string['engineserverstatus'] = 'The search engine is not available. Please contact your administrator.';
|
||||
$string['enteryoursearchquery'] = 'Enter your search query';
|
||||
$string['error_indexing'] = 'An error occurred while indexing';
|
||||
$string['errors'] = 'Errors';
|
||||
$string['errorareanotavailable'] = '{$a} search area is not available.';
|
||||
$string['everywhere'] = 'Everywhere you can access';
|
||||
|
@ -280,6 +280,16 @@ class document implements \renderable, \templatable {
|
||||
} else {
|
||||
// Replace all groups of line breaks and spaces by single spaces.
|
||||
$this->data[$fieldname] = preg_replace("/\s+/u", " ", $value);
|
||||
if ($this->data[$fieldname] === null) {
|
||||
if (isset($this->data['id'])) {
|
||||
$docid = $this->data['id'];
|
||||
} else {
|
||||
$docid = '(unknown)';
|
||||
}
|
||||
throw new \moodle_exception('error_indexing', 'search', '', null, '"' . $fieldname .
|
||||
'" value causes preg_replace error (may be caused by unusual characters) ' .
|
||||
'in document with id "' . $docid . '"');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->data[$fieldname];
|
||||
|
Loading…
x
Reference in New Issue
Block a user