mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-76493 core: make sure format_string(null) works on PHP 8.1
This commit is contained in:
parent
57c1e97bf1
commit
e5f862d0b1
@ -48,6 +48,10 @@ class weblib_test extends advanced_testcase {
|
||||
// Unicode entities.
|
||||
$this->assertSame("ᅻ", format_string("ᅻ"));
|
||||
|
||||
// Nulls.
|
||||
$this->assertSame('', format_string(null));
|
||||
$this->assertSame('', format_string(null, true, ['escape' => false]));
|
||||
|
||||
// < and > signs.
|
||||
$originalformatstringstriptags = $CFG->formatstringstriptags;
|
||||
|
||||
|
@ -1430,6 +1430,11 @@ function reset_text_filters_cache($phpunitreset = false) {
|
||||
function format_string($string, $striplinks = true, $options = null) {
|
||||
global $CFG, $PAGE;
|
||||
|
||||
if ($string === '' || is_null($string)) {
|
||||
// No need to do any filters and cleaning.
|
||||
return '';
|
||||
}
|
||||
|
||||
// We'll use a in-memory cache here to speed up repeated strings.
|
||||
static $strcache = false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user