Problem/Motivation

Unit test CI jobs started failing on PHP 8.6 for deprecations: https://git.drupalcode.org/issue/drupal-3587327/-/jobs/9620873/viewer

RFC: https://wiki.php.net/rfc/eol-oniguruma
Deprecation: [RFC][mbregex] Set deprecate Oniguruma(mbregex)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3588024

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Issue summary: View changes
mondrake’s picture

Issue summary: View changes

dww made their first commit to this issue’s fork.

dww’s picture

Status: Active » Needs review

Thanks for opening this! Was confused why this test was consistently failing.

I did some Git archeology. These lines were added to core/modules/views/src/Plugin/views/field/FieldPluginBase.php in commit 4a9fbaf2150a #1912476: Move views_trim_text to FieldPluginBase.

That issue simply moved the code from views.module. If you blame earlier versions of views.module, this code goes all the way back to the initial commit for Views in core: commit a626abb24fa "Add the 7.x-3.x Views branch." (for which there's no issue NID in the commit message 😢).

Anyway, I pushed an initial commit to simply remove those, and use the fallback of preg_match() instead. This passes locally (still on 8.5):

./vendor/bin/phpunit -c core/phpunit.xml core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php

Opened an MR about it. Let's see what the bot says.

dww’s picture

Bot is happy. Just a random fail in Nightwatch (which I can't re-run, "thanks" to #3576458: [regression] Subsystem and Topics maintainers require access to re-run, trigger, or view tests). Any other changes needed here before RTBC/commit? Would be great to get back to all-green pipelines by default.

Thanks!
-Derek

godotislate’s picture

Status: Needs review » Reviewed & tested by the community

Re-ran the nightwatch tests, and they're green now.

Looked at the MR and it's straightforward. Looking at the old commits referenced in #6, there's definitely existing test coverage. LGTM.

alexpott’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I'm not an expert on multi-byte strings but this removal leads to a what looks like a regression. I was assisted by an LLM in finding this regression.

alexpott’s picture

As you can see on https://git.drupalcode.org/project/drupal/-/pipelines/810759 - the test only pipeline passes but the non-test only pipeline fails because we've removed the mb_ereg() function.

godotislate’s picture

Status: Needs work » Reviewed & tested by the community

Ah, okay. I'm not a multibyte expert either, and it looks like existing test coverage was insufficient.

I did check the deprecation RFC yesterday and there were no suggested alternatives or replacements.

Just did some searching: I'm not sure if anything suggested in this stackoverflow thread is relevant or actually works, but maybe a thread worth pulling: https://stackoverflow.com/questions/1725227/get-multibyte-character-coun...

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Reading the RFC it looks like there is a replacement - https://packagist.org/packages/mb_onig/mb_onig - which adds back the old functions without deprecation. It feels wrong to remove support for this when nothing is currently broken other than a new deprecation message being emitted. The current MR is not mergeable as it includes the test coverage I've added to show the different behaviour - I've asked a hindi speaking friend to confirm that the preg_match behaviour is incorrect and confirm whether or not this change leads to a regression.

andypost’s picture

FYI this functions just been fixed in latest security releases and the most of distros adopted it as a patch but as the library is not supported I bet it's wrong way to use totally untested extension (mb_onig) and archived library

Refs:
- https://github.com/php/php-src/security/advisories/GHSA-wm6j-2649-pv75
- https://github.com/kkos/oniguruma

andypost’s picture

Moreover https://github.com/youkidearitai/mb_onig extension require to build it using pie or bundling into PHP itself.

So the most of end-users will be unable to install it without GCC&co

andypost’s picture

Status: Needs work » Needs review

Added another approach and it pass locally

godotislate’s picture

Oh, whoops, moving to RTBC back in #12 was not intentional. Sorry about that!

godotislate’s picture

Status: Needs review » Reviewed & tested by the community

I have a nit on the MR to go with a ternary, but this is fine for RTBC.

dww’s picture

Agreed with the nit. Applied that suggestion. Bot is still happy. Closed my original MR in favor of the new one. No complaints. Leaving RTBC.

Thanks!
-Derek

alexpott’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed e69457653ca to main and 6db7de3daef to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 6db7de3d on 11.x
    task: #3588024 PHP 8.6 - Functions mb_regex_encoding() and mb_ereg() are...

  • alexpott committed e6945765 on main
    task: #3588024 PHP 8.6 - Functions mb_regex_encoding() and mb_ereg() are...
andypost’s picture

Filed follow-up to promote PHP 8.6 for upcoming release #3590237: Add PHP 8.6 polyfill

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.