Bug #79257 [NEW]: Duplicate named groups ((?J) modifier) broken since 7.4

From: Date: Tue, 11 Feb 2020 13:11:21 +0000
Subject: Bug #79257 [NEW]: Duplicate named groups ((?J) modifier) broken since 7.4
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225491@lists.php.net to get a copy of this message
From: ptomulik at meil dot pw dot edu dot pl Operating system: Debian/Ubuntu PHP version: 7.4.2 Package: PCRE related Bug Type: Bug Bug description:Duplicate named groups ((?J) modifier) broken since 7.4 Description: ------------ It appears, that the "backward incompatible changes" in PHP7.4 - "Regular Expressions", as described here: https://www.php.net/manual/en/migration74.incompatible.php affect named capture groups when duplicate names are enabled ((?J) modifier/PCRE2_DUPMANES config). In 7.4 named capture group always returns the content captured in last alternative, no matter which of the alternatives matched. This differs from 7.3 and renders DUPNAMES feature useless. Test script: --------------- <?php preg_match('/(?J)(?:(?<g>foo)|(?<g>bar))/', 'foo', $matches, PREG_UNMATCHED_AS_NULL); var_dump($matches); ?> Expected result: ---------------- array(4) { [0]=> string(3) "foo" ["g"]=> string(3) "foo" [1]=> string(3) "foo" [2]=> NULL } Actual result: -------------- array(4) { [0]=> string(3) "foo" ["g"]=> NULL [1]=> string(3) "foo" [2]=> NULL } -- Edit bug report at https://bugs.php.net/bug.php?id=79257&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79257&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79257&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79257&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79257&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79257&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79257&r=support Expected behavior: https://bugs.php.net/fix.php?id=79257&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79257&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79257&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79257&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79257&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79257&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79257&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79257&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79257&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79257&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79257&r=mysqlcfg

« previous php.bugs (#225491) next »