PHP Warning: Undefined array key 0 in Has_Multiple_Admins.php line 93 (multisite
-
Hello,
I’m reporting a PHP warning triggered by Site Kit on a multisite installation.
Environment
- WordPress: 6.9.4
- Site Kit: 1.178.0
- PHP: 8.2.28
- Multisite: yes
Warning (full message)
PHP Warning: Undefined array key 0 in /home/jzv4lkm/public_html/wp-content/plugins/google-site-kit/includes/Core/Authentication/Has_Multiple_Admins.php on line 93
(Adjust the filesystem path if you paste this on a different server.)
What happens
When Site Kit evaluates whether the site has multiple administrators, it calls <code class=””>get_super_admins() and then, inside the multisite branch, accesses <code class=””>$super_admins[0] after only checking <code class=””>! empty( $super_admins ).In PHP 8+, that triggers “Undefined array key 0” when the array is non-empty but does not have a <code class=””>0 key (e.g. a sparse / non–zero-indexed array), which can occur depending on how the super admin list is stored or filtered.
Suggested direction
Before using <code class=””>$super_admins[0], the code could guard with <code class=””>isset( $super_admins[0] ) or normalize with something like <code class=””>$login = reset( $super_admins ); / <code class=””>array_values( $super_admins ) so the first login is read safely.Expected behavior
No PHP warnings when counting administrators on multisite.Thank you for considering a fix in a future release.
You must be logged in to reply to this topic.