Unexpected error: foreach() argument must be of type array|object, null given in ContactFormFieldVO.php on line 142

Got the following error trying to check contacts page (admin):

Unexpected error: foreach() argument must be of type array|object, null given in ContactFormFieldVO.php on line 142

For good measure, I updated all the BL5 modules:

PHP Level is 8.1 (Godaddy)

Looks like module-admin is not current.

It does look that way, however, notice “Reinstall” is not off to the right like all the other modules. That is the state after I did an Update All. I just tried Update All again with same result.

Checked the error log and have the following errors:
[20-Jan-2025 23:53:41 UTC] PHP Warning: ZipArchive::extractTo(…/backlight/modules/module-admin/application/views/admin/phpinfo.php): Failed to open stream: Permission denied in /home/michaelboatright/public_html/backlight/modules/module-framework/helpers/InstallerClient.php on line 117
[20-Jan-2025 23:54:08 UTC] PHP Warning: foreach() argument must be of type array|object, null given in /home/michaelboatright/public_html/backlight/modules/module-admin/application/models/ContactFormFieldVO.php on line 142
[20-Jan-2025 23:59:31 UTC] PHP Warning: foreach() argument must be of type array|object, null given in /home/michaelboatright/public_html/backlight/modules/module-admin/application/models/ContactFormFieldVO.php on line 142
[21-Jan-2025 01:09:49 UTC] PHP Warning: ZipArchive::extractTo(…/backlight/modules/module-admin/application/views/admin/phpinfo.php): Failed to open stream: Permission denied in /home/michaelboatright/public_html/backlight/modules/module-framework/helpers/InstallerClient.php on line 117
[21-Jan-2025 01:12:16 UTC] PHP Warning: ZipArchive::extractTo(…/backlight/modules/module-admin/application/views/admin/phpinfo.php): Failed to open stream: Permission denied in /home/michaelboatright/public_html/backlight/modules/module-framework/helpers/InstallerClient.php on line 117

Here is a grab of /backlight/modules/module-admin/application

and /backlight/modules/module-admin/application/views

and /backlight/modules/module-admin/application/views/admin (part 1 of 2)

and /backlight/modules/module-admin/application/views/admin part 2 of 2:

I see that the offending module in the error log is phpinfo.php and it is zero bytes. But nothing seems wrong with the permissions.

I took a chance and “deleted” (did not permanently delete)
/backlight/modules/module-admin/application/views/admin/phpinfo.php (the one with zero bytes)
and reran Update All. This time it ran clean and did not get the error message in the log. Now has 99 bytes.

Here is result of Special Links/View PHP Info

[View PHP Info: PHP 8.1.31 - phpinfo()](View PHP Info: PHP 8.1.31 - phpinfo())

Installed PHP Modules:
Core
date
libxml
openssl
pcre
sqlite3
zlib
bz2
calendar
ctype
curl
hash
filter
ftp
gettext
json
iconv
SPL
pcntl
readline
Reflection
session
standard
mbstring
shmop
SimpleXML
tokenizer
xml
litespeed
i360
bcmath
dom
fileinfo
gd
imagick
imap
inotify
intl
exif
mcrypt
mysqli
mysqlnd
PDO
pdo_mysql
pdo_sqlite
Phar
posix
soap
xmlreader
xmlwriter
zip
Zend OPcache

View PHP Info: PHP 8.1.31 - phpinfo()

That’s something for @Ben to look at. To accelerate things, I would send him your backlight admin and ftp logins/passwords. When you hover over his name, there’s a popup where you directly can message him.

A link to your site could be helpful too.

Thanks. I sent @ben a message.

Hi @michaelboatright, this is an error that comes up for newer versions of PHP on Backlight 5. It happens when the contact form has no extra fields configured.
While not pretty, the message shouldn’t affect site functionality.

Gotcha.

Interesting, I added a required field to the form and still get the message. Is this because I have older contacts without that field?

I plan to upgrade to 6…just trying to get a few things squared away in 5 first!

Thanks!

Hi @michaelboatright, I think you’re right. This would be affected by the data within the Contacts, so would come up if previous contacts didn’t include additional fields. I think it may go further back than that - Contacts that include nothing in the extra fields column rather than an empty array…

Since this affects PHP versions that were current before Backlight 6 came out, I’ve pushed a fix for this. Please update your site to Backlight 5.4.2.

1 Like