|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-06-21 11:35 UTC] hans at reachdigital dot nl
Description: ------------ While debugging an issue (within Magento), I stumbled upon a case where preg_match() is giving an unexpected result compared to previous PHP versions. In our case a given pattern is matching two particular strings on older PHP versions, but fails to match one of them in PHP 7.4.16 (as well as PHP 8.0.6) Please refer to the test script I've added, which when run with PHP 7.4.16 indicates that the pattern matches both strings, but when run with PHP 7.4.20 indicates that only one string matches. Interestingly, putting something like '.+' at the beginning of the pattern makes it work as expected again Test script: --------------- $pattern = "#/(?<moduleName>[^/]+)/layout/[^/]*\.xml$#i"; $res1 = preg_match($pattern, "/Users/nickdekleijn/Sites/project-12gobiking-m2/vendor/magento/theme-adminhtml-backend/Magento_Backend/layout/default.xml", $matches); $res2 = preg_match($pattern, "/Users/wimvanderputten/Documents/gob/project-12gobiking-m2/vendor/magento/theme-adminhtml-backend/Magento_Backend/layout/default.xml", $matches); var_dump($res1); var_dump($res2); Expected result: ---------------- int(1) int(1) Actual result: -------------- int(0) int(1) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 14:00:01 2025 UTC |
Hey there, a few colleagues of mine who are both running into this issue (I am running 7.4.20 myself so am not affected) report that adding `ini_set("pcre.jit", "0")` to the test script does indeed make it give the expected result