Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Error: Call to undefined function mb_regex_encoding() in .../vendor/voku/portable-utf8/src/voku/helper/UTF8.php:536 #205

Open
MocioF opened this issue Mar 21, 2024 · 0 comments

Comments

@MocioF
Copy link

MocioF commented Mar 21, 2024

I'm experiencing a PHP Fatal error while using portable-utf8 in a wordpress plugin when PHP is built with'--enable-mbstring' '--disable-mbregex' (which is the case, at the current date, for deployed WordPress/wordpress-playground).

As in topic, the error is:
Uncaught Error: Call to undefined function mb_regex_encoding() in .../vendor/voku/portable-utf8/src/voku/helper/UTF8.php:536

It seems that while detecting for UTF8 support,

self::$SUPPORT['mbstring'] = self::mbstring_loaded();

portable-utf8 checks for extension_loaded('mbstring')

return \extension_loaded('mbstring');

and then it takes it for granted that mb_regex_encoding() is available.

\mb_regex_encoding('UTF-8');

But mb_regex_encoding() is available only when PHP is built without '--disable-regex' https://www.php.net/manual/en/mbstring.installation.php

A related possible problem is that symfony/polyfill-mbstring does not provide polyfills for mbregex function.
The only package I have found that can provide polyfill for mbregex is zendtech/polyfill-mb-ereg but even if it declares to provide a polyfill for mb_regex_encoding(), the code is:
https://github.com/zendtech/polyfill-mb-ereg/blob/813e5b2d0669a8c619e6b5439916b2e5d20d7af0/src/MbEreg.php#L58C1-L65C6
However I didn't test any patch to see what happens using this library.

MocioF added a commit to MocioF/No-unsafe-inline that referenced this issue Apr 13, 2024
Signed-off-by: Giuseppe Foti <foti.giuseppe@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant