diff --git a/lib/mustache/readme_moodle.txt b/lib/mustache/readme_moodle.txt index fc614724699..75b29f4ae75 100644 --- a/lib/mustache/readme_moodle.txt +++ b/lib/mustache/readme_moodle.txt @@ -20,3 +20,6 @@ from the list. If still not available upstream, they will need to be re-applied. - MDL-67114: PHP 7.4 compatibility. Array operations on scalar value. This corresponds to upstream https://github.com/bobthecow/mustache.php/pull/352 +- MDL-73586: PHP 8.0 compatibility. Removed 'mbstring.func_overload' init setting. + This corresponds to upstream commit https://github.com/bobthecow/mustache.php/commit/e7165a33b282ab4d20b3863825caadb46313d62b + that is availbale for the library versions 2.14.1 and up diff --git a/lib/mustache/src/Mustache/Tokenizer.php b/lib/mustache/src/Mustache/Tokenizer.php index 6dbe0cdfa03..71871226a34 100644 --- a/lib/mustache/src/Mustache/Tokenizer.php +++ b/lib/mustache/src/Mustache/Tokenizer.php @@ -97,11 +97,16 @@ class Mustache_Tokenizer // Setting mbstring.func_overload makes things *really* slow. // Let's do everyone a favor and scan this string as ASCII instead. // + // The INI directive was removed in PHP 8.0 so we don't need to check there (and can drop it + // when we remove support for older versions of PHP). + // // @codeCoverageIgnoreStart $encoding = null; - if (function_exists('mb_internal_encoding') && ini_get('mbstring.func_overload') & 2) { - $encoding = mb_internal_encoding(); - mb_internal_encoding('ASCII'); + if (version_compare(PHP_VERSION, '8.0.0', '<')) { + if (function_exists('mb_internal_encoding') && ini_get('mbstring.func_overload') & 2) { + $encoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } } // @codeCoverageIgnoreEnd