|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-06-23 19:43 UTC] advocat at gmail dot com
Description: ------------ From manual page: https://php.net/function.preg-match --- PHP 7.4.20 (cli) (built: Jun 4 2021 03:32:07) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.20, Copyright (c), by Zend Technologies Test script: --------------- $pattern = "#/(?<moduleName>[^/]+)/layout/[^/]*\.xml$#i"; $filename = "/var/www/project/vendor/magento/theme-frontend-blank/Magento_Theme/layout/default_head_blocks.xml"; var_dump(preg_match($pattern, $filename, $matches), $matches); $pattern = "#/([^/]+)/layout/[^/]*\.xml$#i"; var_dump(preg_match($pattern, $filename, $matches), $matches); Expected result: ---------------- int(1) array(3) { [0]=> string(45) "/Magento_Theme/layout/default_head_blocks.xml" ["moduleName"]=> string(13) "Magento_Theme" [1]=> string(13) "Magento_Theme" } int(1) array(2) { [0]=> string(45) "/Magento_Theme/layout/default_head_blocks.xml" [1]=> string(13) "Magento_Theme" } Actual result: -------------- int(0) array(0) { } int(0) array(0) { } PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 21:00:02 2025 UTC |
Please try disabling pcre.jit with `ini_set("pcre.jit", "0")` possibly dupe of https://bugs.php.net/bug.php?id=81185This is reproduce on OS Big Sur x64 (looks like OS specific) I've tried to use compiled version from homebrew and tried to build from source Some interesting cases: --- $ php -i | grep pcre Configure Command => './configure' '--prefix=/usr/local/Cellar/php@7.4/7.4.20' '--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/7.4' '--with-config-file-path=/usr/local/etc/php/7.4' '--with-config-file-scan-dir=/usr/local/etc/php/7.4/conf.d' '--with-pear=/usr/local/Cellar/php@7.4/7.4.20/share/php@7.4/pear' '--enable-bcmath' '--enable-calendar' '--enable-dba' '--enable-exif' '--enable-ftp' '--enable-fpm' '--enable-gd' '--enable-intl' '--enable-mbregex' '--enable-mbstring' '--enable-mysqlnd' '--enable-pcntl' '--enable-phpdbg' '--enable-phpdbg-readline' '--enable-phpdbg-webhelper' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-apxs2=/usr/local/opt/httpd/bin/apxs' '--with-bz2=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr' '--with-curl' '--with-external-gd' '--with-external-pcre' '--with-ffi' '--with-fpm-user=_www' '--with-fpm-group=_www' '--with-gettext=/usr/local/opt/gettext' '--with-gmp=/usr/local/opt/gmp' '--with-iconv=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr' '--with-kerberos' '--with-layout=GNU' '--with-ldap=/usr/local/opt/openldap' '--with-libxml' '--with-libedit' '--with-mhash=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-ndbm=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr' '--with-openssl' '--with-password-argon2=/usr/local/opt/argon2' '--with-pdo-dblib=/usr/local/opt/freetds' '--with-pdo-mysql=mysqlnd' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--with-pdo-pgsql=/usr/local/opt/libpq' '--with-pdo-sqlite' '--with-pgsql=/usr/local/opt/libpq' '--with-pic' '--with-pspell=/usr/local/opt/aspell' '--with-sodium' '--with-sqlite3' '--with-tidy=/usr/local/opt/tidy-html5' '--with-unixODBC' '--with-xmlrpc' '--with-xsl' '--with-zip' '--with-zlib' '--enable-dtrace' '--with-ldap-sasl' '--with-os-sdkpath=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' 'PKG_CONFIG_PATH=/usr/local/opt/apr/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/argon2/lib/pkgconfig:/usr/local/opt/brotli/lib/pkgconfig:/usr/local/opt/libidn2/lib/pkgconfig:/usr/local/opt/libmetalink/lib/pkgconfig:/usr/local/opt/libssh2/lib/pkgconfig:/usr/local/opt/c-ares/lib/pkgconfig:/usr/local/opt/jemalloc/lib/pkgconfig:/usr/local/opt/nghttp2/lib/pkgconfig:/usr/local/opt/openldap/lib/pkgconfig:/usr/local/opt/rtmpdump/lib/pkgconfig:/usr/local/opt/zstd/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/unixodbc/lib/pkgconfig:/usr/local/opt/libpng/lib/pkgconfig:/usr/local/opt/freetype/lib/pkgconfig:/usr/local/opt/fontconfig/lib/pkgconfig:/usr/local/opt/jpeg/lib/pkgconfig:/usr/local/opt/libtiff/lib/pkgconfig:/usr/local/opt/webp/lib/pkgconfig:/usr/local/opt/gd/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/pcre/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/sqlite/lib/pkgconfig:/usr/local/opt/xz/lib/pkgconfig:/usr/local/opt/python@3.9/lib/pkgconfig:/usr/local/opt/glib/lib/pkgconfig:/usr/local/opt/gmp/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/libpq/lib/pkgconfig:/usr/local/opt/libsodium/lib/pkgconfig:/usr/local/opt/libzip/lib/pkgconfig:/usr/local/opt/oniguruma/lib/pkgconfig:/usr/local/opt/pcre2/lib/pkgconfig:/usr/local/opt/tidy-html5/lib/pkgconfig' 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/11' 'KERBEROS_CFLAGS= ' 'SASL_CFLAGS=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sasl' 'SASL_LIBS=-lsasl2' pcre pcre.backtrack_limit => 1000000 => 1000000 pcre.jit => 1 => 1 pcre.recursion_limit => 100000 => 100000 --- I've tried to play with values and now the script --- <?php $pattern = "#/(?<moduleName>[^/]+)/layout/[^/]*\.xml$#i"; $filename = "/var/www/project/vendor/magento/theme-frontend-blank/Magento_Theme/layout/default_head_blocks.xml"; var_dump(preg_match($pattern, $filename, $matches), $matches); $filename = "/var/www/project/name/vendor/magento/theme-frontend-blank/Magento_Theme/layout/default_head_blocks.xml"; var_dump(preg_match($pattern, $filename, $matches), $matches); --- Outputs --- int(1) array(3) { [0]=> string(45) "/Magento_Theme/layout/default_head_blocks.xml" ["moduleName"]=> string(13) "Magento_Theme" [1]=> string(13) "Magento_Theme" } int(0) array(0) { } --- I cannot reproduce the issue with 3v4l> When i force disabled pcre.jit in config - looks like this is > solve the issue Great! Which PCRE version do you use? <?php echo PCRE_VERSION ?;