preg_match() syntax throwing errors in recent PHP
-
In a number of places, megamenu uses
preg_match()
, and passesnull
as the fourth$flags
parameter.preg_match()
expects an integer here, and recent versions of PHP (8.1+, I think) throw a notice for this incorrect usage.One of my clients runs megamenu on a popular webhost that logs these kinds of errors by default, and in this case the excessive I/O to the error log caused the site to crash ??
As I noted, the usage happens in a number of places through megamenu. Here’s one example stack trace: https://gist.github.com/boonebgorges/373d8cacf849039f41255a59d730aa07
Here’s a patch to fix the issue, switching
null
to0
in all relevant places. (the patch is derived from the WP root, so you may need to usepatch -p4
to apply it in the megamenu directory). https://gist.github.com/boonebgorges/c313f10004750669f1643b840de1aa1b
- The topic ‘preg_match() syntax throwing errors in recent PHP’ is closed to new replies.