PHP 8 issues - Deprecated: preg_match()

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 22, 2022   (RSS)

By daniel - June 21, 2022

Thanks for the report Deborah!

This should be fixed for the next CMSB version, but in the meantime, it can be patched by replacing line 250 with this:

$startsWithHttpOrSlash = preg_match("|^(\w+:/)?/|", $_REQUEST[$name]??'');

Also, just to arm you in case you run across similar unpatched PHP 8.1 deprecation warnings (specifically ones that mention "passing null"), note which function and parameter is throwing the warning (in this case, preg_match() and parameter #2), and add ??'' to the end of the variable being passed to that parameter. It's also possible to remove the @ from the variable if there is one. So this:

@$_REQUEST[$name]

became this:

$_REQUEST[$name]??''

This isn't a fix for 100% of cases, but something worth trying to get the warning cleared up ASAP. Though we always appreciate reports like this regardless!

Cheers,

Daniel
Technical Lead
interactivetools.com

By Deborah - June 22, 2022 - edited: June 22, 2022

Daniel,

Your fix worked!

I'll take note of your suggestion if I should see that type of warning again.

Thanks so much!
Deborah