Fix for DataTables warning on Clients screen and type bool error on groups.php line 208

Posting this here in case it helps others and if someone more familiar with the project feels it should be a PR, maybe convert it into one.

My Pi-Hole instance somehow ended up with a client in the database without a name. I don't know how that happened, but it did.

This resulted in an error message popup in the web UI that read:

DataTables warning: table id=clientsTable - Invalid JSON response. For more information about this error, please see 1. Warning: Invalid JSON response

It also resulted in a repeated entry in the log:

Trying to access array offset on value of type bool in /var/www/pihole/admin/scripts/pi-hole/php/groups.php on line 208

I fixed the problem by editing admin/scripts/pi-hole/php/groups.php and changing line 208 from:

$res['name'] = $name_result['name'];

to:

$res['name'] = is_array($name_result) ? $name_result['name'] : '';

Once I did this, I could clearly see the client without a name and work within the system again.

I hope this helps the next guy/gal and if someone more confident this wasn't a stupid move wants to convert this into a PR, that would be wonderful.

Related:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.