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

PHP Extension: add support for mbregex #815

Closed
jakejackson1 opened this issue Nov 27, 2023 · 6 comments · Fixed by #884 or #1155
Closed

PHP Extension: add support for mbregex #815

jakejackson1 opened this issue Nov 27, 2023 · 6 comments · Fixed by #884 or #1155
Assignees
Labels

Comments

@jakejackson1
Copy link

When the mbstring PHP extension is enabled, it would be useful to enable the multibyte regex functions, too. They are currently always disabled: https://github.com/WordPress/wordpress-playground/blob/trunk/packages/php-wasm/compile/Dockerfile#L509

@adamziel
Copy link
Collaborator

Thank you for reporting @jakejackson1! I understand your plugin relies on mbregex?

@jakejackson1
Copy link
Author

@adamziel yes. The PDF library used in a plugin I help develop uses the mbregex functions. A couple of other popular plugins include the same PDF library:

https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/
https://wordpress.org/plugins/gravity-forms-pdf-extended/
https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/

@adamziel
Copy link
Collaborator

PHP configuration–wise, the --enable-mbregex enables the mbregex extension.

However, mbregex requires the https://github.com/kkos/oniguruma library and it would have to be included as a dependency among other libraries already used (like libpng).

@adamziel adamziel self-assigned this Dec 19, 2023
adamziel added a commit that referenced this issue Dec 19, 2023
## What is this PR doing?

Adds the `mbregex` extension to the kitchen sink bundle. This also makes
it available on the website when the "Load extensions" checkbox is
clicked.

Closes #815

## Testing Instructions

1. Apply this PR
2. Open Playground, go to `/phpinfo.php`
3. Look up the mbregex extension and oniguruma
4. Confirm they're both installed
@MocioF
Copy link

MocioF commented Mar 18, 2024

My plugin still fails on activate with Uncaught Error: Call to undefined function mb_regex_encoding() in /wordpress/wp-content/plugins/no-unsafe-inline/vendor/voku/portable-utf8/src/voku/helper/UTF8.php:536

The issue seems to be confirmed, because in https://playground.wordpress.net/ if I activate the plugin phpinfo https://wordpress.org/plugins/phpinfo-wp/ ( using PHP VERSION 8.1.23-DEV) it shows me as Configure Command:

'./configure' 'PKG_CONFIG_PATH=/root/lib/lib/pkgconfig' '--disable-fiber-asm' '--enable-phar' '--enable-json' '--enable-embed=static' '--with-layout=GNU' '--disable-cgi' '--disable-all' '--enable-hash' '--enable-static=yes' '--enable-shared=no' '--enable-session' '--enable-filter' '--enable-calendar' '--disable-rpath' '--disable-phpdbg' '--without-pear' '--with-valgrind=no' '--without-pcre-jit' '--enable-bcmath' '--enable-ctype' '--enable-tokenizer' '--with-zlib' '--with-zlib-dir=/root/lib' '--with-zip' '--disable-cli' '--enable-libxml' '--with-libxml' '--with-libxml-dir=/root/lib' '--enable-dom' '--enable-xml' '--enable-simplexml' '--enable-xmlreader' '--enable-xmlwriter' '--with-sqlite3' '--enable-pdo' '--with-pdo-sqlite=/root/lib' '--with-png-dir=/root/lib' '--with-gd' '--enable-gd' '--with-openssl' '--with-openssl-dir=/root/lib' '--with-iconv=/root/lib' '--enable-mbstring' '--disable-mbregex'

@adamziel
Copy link
Collaborator

adamziel commented Mar 19, 2024

It seems like a regression, thank you for reporting @MocioF. I've added this issue to the project board with a high priority. Let's include a unit test with the fix to ensure the mbregex extension keeps working over time.

@adamziel adamziel reopened this Mar 19, 2024
@adamziel adamziel added this to the Zero Crashes milestone Mar 19, 2024
@adamziel adamziel removed their assignment Mar 21, 2024
@bgrgicak bgrgicak self-assigned this Mar 26, 2024
@bgrgicak
Copy link
Collaborator

The issue is in this if. PHP versions can be 8.0.30 and this doesn't work.

I have a fix and am working on some tests to ensure it doesn't break again.

bgrgicak added a commit that referenced this issue Apr 1, 2024
Fixes #815

## What is this PR doing?

It fixes support for `mbregex` and adds a test to ensure it keeps
working.

## What problem is it solving?

Ensures support for `mbregex`.

## How is the problem addressed?

By fixing a `if` condition in the Docker file that prevented PHP > 7.0
from enabling `mbregex`.
Also, the code wrongly assumed that PHP 7.4 includes `oniguruma`, but it
doesn't, so it's now added to PHP 7.4.

## Testing Instructions
- ensure tests pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
4 participants