PHP 8.6 - Functions mb_regex_encoding() and mb_ereg() are deprecated #3588024

I updated the approach so we do not replace mb_ereg() with plain PCRE \b.

The earlier preg_match('/\b/u') fallback can trim incorrectly for Indic scripts because PCRE word boundaries may see a boundary inside text that uses combining marks. For example, with हिंदी परीक्षण स्ट्रिंग truncated to 10 characters, plain PCRE can return हिंदी परी instead of stopping at the previous word boundary.

The patch now uses Drupal’s existing Unicode::PREG_CLASS_WORD_BOUNDARY instead. That keeps the replacement inside core, avoids the PHP 8.6 mb_regex_encoding() / mb_ereg() deprecations, and uses the Unicode boundary definition Drupal already relies on in Unicode::truncate().

I also added a Hindi regression case to FieldKernelTest::testTrimText():

  • without word boundary: हिंदी परीक
  • with word boundary: हिंदी

This should preserve the existing Vietnamese and Cyrillic behavior while avoiding the Indic-language regression from plain \b.

Merge request reports

Loading