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:
e7165a33b2

And it has been released with version 2.14.1 of the library, so, once
we upgrade to it, the fix will be incorporated.
This commit is contained in:
Eloy Lafuente (stronk7) 2022-03-08 12:31:20 +01:00
parent bb864ee2e1
commit 8a6a7d7e36
2 changed files with 11 additions and 3 deletions

View file

@ -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

View file

@ -97,12 +97,17 @@ 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 (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
$this->reset();