You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a result, $auto_updates remains an empty string, which causes an exception later at Plugin_Command.php:720:
'auto_update' => in_array( $file, $auto_updates, true ),
The in_array function expects the haystack to be an array, and passing a string results in an exception.
According to the WordPress documentation, the get_site_option function can return a mixed value, but I'm not sure why it returns an empty string in this case.
PHP 8.0 in_array change
In PHP 8.0 and later, passing a non-array value to in_array results in a TypeError. In PHP 7.x and earlier, this would emit a warning and return false.
Workaround
My current workaround is to remove the strict comparison check: if ( false == $auto_updates ) {
Can you provide guidance on how to handle this scenario properly? Should there be an additional check to ensure $auto_updates is an array before using it in in_array?
Thanks for your help!
The text was updated successfully, but these errors were encountered:
Hi,
Issue
I've encountered an issue where get_site_option returns an empty string. This happens at Plugin_Command.php:694.
$auto_updates = get_site_option( Plugin_AutoUpdates_Command::SITE_OPTION );
Due to this, the following condition does not catch the empty string:
As a result, $auto_updates remains an empty string, which causes an exception later at Plugin_Command.php:720:
'auto_update' => in_array( $file, $auto_updates, true ),
The in_array function expects the haystack to be an array, and passing a string results in an exception.
According to the WordPress documentation, the get_site_option function can return a mixed value, but I'm not sure why it returns an empty string in this case.
PHP 8.0 in_array change
In PHP 8.0 and later, passing a non-array value to in_array results in a TypeError. In PHP 7.x and earlier, this would emit a warning and return false.
Workaround
My current workaround is to remove the strict comparison check:
if ( false == $auto_updates ) {
Can you provide guidance on how to handle this scenario properly? Should there be an additional check to ensure $auto_updates is an array before using it in in_array?
Thanks for your help!
The text was updated successfully, but these errors were encountered: