From 254108755afe13cdb2a79befa71c3edd27c1ea2f Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 8 Mar 2022 12:31:20 +0100 Subject: [PATCH] MDL-73586 mustache.php: Removed php init param for php80 and up The 'mbstring.func_overload' php init setting was removed for php80 (it was deprecated since php72). So it won't evaluate to true ever, so the whole block can be put under php version condition. Note that this is already fixed upsteam, for commit: https://github.com/bobthecow/mustache.php/commit/e7165a33b282ab4d20b3863825caadb46313d62b And it has been released with version 2.14.1 of the library, so, once we upgrade to it, the fix will be incorporated. --- lib/mustache/readme_moodle.txt | 3 +++ lib/mustache/src/Mustache/Tokenizer.php | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) 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