mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 03:46:42 +02:00
MDL-60943 core_search: Improve exception for preg_replace errors
This commit is contained in:
parent
51e05c09c3
commit
0ce4a24888
2 changed files with 11 additions and 0 deletions
|
@ -51,6 +51,7 @@ $string['enginenotinstalled'] = 'Engine {$a} is not installed.';
|
||||||
$string['enginenotselected'] = 'You have not selected any search engine.';
|
$string['enginenotselected'] = 'You have not selected any search engine.';
|
||||||
$string['engineserverstatus'] = 'The search engine is not available. Please contact your administrator.';
|
$string['engineserverstatus'] = 'The search engine is not available. Please contact your administrator.';
|
||||||
$string['enteryoursearchquery'] = 'Enter your search query';
|
$string['enteryoursearchquery'] = 'Enter your search query';
|
||||||
|
$string['error_indexing'] = 'An error occurred while indexing';
|
||||||
$string['errors'] = 'Errors';
|
$string['errors'] = 'Errors';
|
||||||
$string['errorareanotavailable'] = '{$a} search area is not available.';
|
$string['errorareanotavailable'] = '{$a} search area is not available.';
|
||||||
$string['filesinindexdirectory'] = 'Files in index directory';
|
$string['filesinindexdirectory'] = 'Files in index directory';
|
||||||
|
|
|
@ -280,6 +280,16 @@ class document implements \renderable, \templatable {
|
||||||
} else {
|
} else {
|
||||||
// Replace all groups of line breaks and spaces by single spaces.
|
// Replace all groups of line breaks and spaces by single spaces.
|
||||||
$this->data[$fieldname] = preg_replace("/\s+/u", " ", $value);
|
$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];
|
return $this->data[$fieldname];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue