====== PHP RFC: Oniguruma maintenance end and end of mbregex ======
* Version: 0.1
* Date: 2025-08-21
* Author: Yuya Hamada youkidearitai@gmail.com
* Status: Voting
* Implementation: https://github.com/php/php-src/pull/21490
===== Introduction =====
[[https://github.com/kkos/oniguruma|Oniguruma]] maintenance ended on 2025-04-24. PHP uses mbregex (mb_ereg...) functions. So we decide future of mbregex. This proposal is to end support for mbregex in PHP 9.0 and deprecate in 8.6.
===== Proposal =====
Deprecate mbregex functions in PHP 8.6, remove in 9.0.
Deprecated: Function mb_ereg_replace() is deprecated since 8.6, Oniguruma functions support ends PHP 9.0 in %s on line %d
It is likely that the following points need to be decided, and how we will maintain versions 8.2 - 8.5.
* Maintenance versions: 8.2, 8.3, 8.4, 8.5
* Mbregex instead of mb_onig
* Deprecate version: 8.6 (next after 8.5)
* Drop support: 9.0
Maintenance versions can use mbregex functions. However, FreeBSD will drop support on 2026-12-01 (ref: https://github.com/php/php-src/issues/18467#issuecomment-3044192511). We should decide what we will do after EOL in FreeBSD. (This affects CI in the php-src repository)
I suggest:
* External packaging, for example [[https://github.com/youkidearitai/mb_onig/]] (created by me)
* Disable mbregex in configure option (--disable-mbregex)
===== Drop the following mbregex functions =====
* mb_ereg
* mb_ereg_match
* mb_ereg_replace
* mb_ereg_replace_callback
* mb_ereg_search
* mb_ereg_search_getpos
* mb_ereg_search_getregs
* mb_ereg_search_init
* mb_ereg_search_pos
* mb_ereg_search_regs
* mb_ereg_search_setpos
* mb_eregi
* mb_eregi_replace
* mb_regex_encoding
* mb_regex_set_options
* mb_split
==== Constants ====
* MB_ONIGURUMA_VERSION
==== php.ini options ====
* mbstring.regex_retry_limit
* mbstring.regex_stack_limit
===== Forked from Oniguruma =====
In Ruby, There is a [[https://github.com/k-takata/Onigmo|Onigmo]] forked from Oniguruma.
However, Onigmo is different than Oniguruma.
* Performance (faster than Oniguruma)
* Unicode version
* Some expressions: `\K`, `\R`, `(?(cond)yes|no)`
* Source: https://github.com/k-takata/Onigmo/blob/master/README
===== Libraries that depend on Oniguruma (estimated) =====
I quoted from https://news-web.php.net/php.internals/130429
Uses code from Juliette: https://gist.github.com/jrfnl/bd0f66f1c185930427db4f093babf214
Summary of findings:
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
-------------------------------------------------------------------------------------------
SOURCE COUNT
-------------------------------------------------------------------------------------------
PHPCompatibility.FunctionUse.RemovedFunctions.mb_splitDeprecated 30
PHPCompatibility.FunctionUse.RemovedFunctions.mb_regex_encodingDeprecated 25
PHPCompatibility.FunctionUse.RemovedFunctions.mb_eregi_replaceDeprecated 20
PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_replaceDeprecated 18
PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_matchDeprecated 13
PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_initDeprecated 10
PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_regsDeprecated 9
PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_replace_callbackDeprecated 6
PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_getregsDeprecated 5
PHPCompatibility.FunctionUse.RemovedFunctions.mb_eregDeprecated 4
PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_setposDeprecated 4
PHPCompatibility.FunctionUse.RemovedFunctions.mb_eregiDeprecated 2
PHPCompatibility.FunctionUse.RemovedFunctions.mb_ereg_search_posDeprecated 1
-------------------------------------------------------------------------------------------
A TOTAL OF 147 SNIFF VIOLATIONS WERE FOUND IN 13 SOURCES
-------------------------------------------------------------------------------------------
Thanks, Juliette.
However, proprietary software probably uses mbregex functions, so impact is larger than that result.
===== External packaging for mb_onig =====
This RFC has a big impact on multibyte (not UTF-8) users.
Therefore, I created bailout extension mb_onig [[https://packagist.org/packages/mb_onig/mb_onig]] so PHP 8.x can still use mbregex functions and we can still maintain mbregex for PHP 9.x.
=== Why the name is `mb_onig`? ===
Debian/Ubuntu users call Oniguruma `onig`. I quoted this.
$ sudo apt search onig
libonig-dev/noble,now 6.9.9-1build1 amd64 [installed]
regular expressions library — development files
libonig5/noble,now 6.9.9-1build1 amd64 [installed,automatic]
regular expressions library
==== PHP 8.x ====
./configure --enable-mbstring --disable-mbregex
make
make install
pie install mb_onig/mb_onig
==== PHP 9 ====
./configure --enable-mbstring
make
make install
pie install mb_onig/mb_onig
===== Backward Incompatible Changes =====
The mbregex functions cannot be used.
===== Proposed PHP Version(s) =====
Deprecate for 8.6 and remove in 9.0.
===== RFC Impact =====
==== To Existing Extensions ====
Mbregex
==== To SAPIs ====
Describe the impact to CLI, Development web server, embedded PHP etc.
===== Open Issues =====
https://github.com/php/php-src/issues/18467
===== Future Scope =====
This section should outline areas that you are not planning to work on in the scope of this RFC, but that might be iterated upon in the future by yourself or another contributor.
This helps with long-term planning and ensuring this RFC does not prevent future work.
===== Voting Choices =====
Primary Vote requiring a 2/3 majority to accept the RFC:
* Yes
* No
* Abstain
===== Implementation =====
* Re-include Oniguruma version: https://github.com/php/php-src/pull/19258
* mb_onig: https://github.com/youkidearitai/mb_onig
* Packagist: https://packagist.org/packages/mb_onig/mb_onig
* Deprecate mbregex: https://github.com/php/php-src/pull/21490
===== References =====
* [[http://ml.php.gr.jp/pipermail/php-dev/2003-August/000844.html|Mailing list when mbregex was changed to Oniguruma (Japanese mailing list ml.php.gr.jp)]]
* https://externals.io/message/127245#127245
===== Rejected Features =====
Keep this updated with features that were discussed on the mail lists.
===== Changelog =====
If there are major changes to the initial proposal, please include a short summary with a date or a link to the mailing list announcement here, as not everyone has access to the wikis' version history.