PHP 8.1 ERRORS (VARIOUS) - Aug 30th, 2022


Thanks to CMSB user Deborah and Daniel Louwe Lead Technician at Interactive Tools for this one...

Deborah was getting the following error when using PHP8.1 with CMSB Version 3.56

Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in
/home/myweb/public_html/cms/lib/menus/database/editTable_functions.php on line 250 Warning: Cannot modify header
information - headers already sent by (output started at
/home/myweb/public_html/cms/lib/menus/database/editTable_functions.php:250) in
/home/myweb/public_html/cms/lib/menus/header.php on line 4

and line 250 in editTablefunctions.php looked like this:

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

Daniel offered the following:

To get rid of PHP 8.1 deprecation warnings (specifically ones that mention "passing null"), note which function and
parameter is throwing the warning (in this example, 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 on line 250, this:

@$_REQUEST[$name]

becomes this:

$_REQUEST[$name]??''

There's another similar error noted in this post: https://www.interactivetools.com/forum/forum-posts.php?postNum=2245997

Other PHP 8 errors and some fixes are talked about in
https://www.interactivetools.com/forum/forum-posts.php?postNum=2246123
and https://www.interactivetools.com/forum/forum-posts.php?postNum=2246122



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service