If you’re using Nagios to monitor your WordPress installations, you may be using the ‘Check WordPress Update’ plugin by jinjie found here:
We recently updated our PHP version on some of our servers to version 8, and this broke the old version of the plugin. The new plugin has been updated and is compatible with PHP version 8.
The incompatibility was with the last line in the code:
echo $status . '#' . implode(';', $text);
The issue arises because of the order of the arguments for the implode function. The old signature, used for PHP versions up to 7.4 was:
implode(array $array, string $separator): string
whereas the new signature for PHP versions greater than 7.4 is:
implode(string $separator, array $array): string
If you’re on a machine which hosts multiple PHP versions and want to just use one version of the plugin, you can use this little modification to check the current PHP version:
//Test if we're using php version 8 or greater. This fix is needed or a fatal error will occur.
if (version_compare(phpversion(), '8', '<')) {
// php version is below 8
echo $status . '#' . implode($text, ';');
} else {
echo $status . '#' . implode(';', $text);
}