Fix for:
Warning: Trying to access array offset on value of type bool in color_field_requirements() (line 49 of /sites/all/modules/contrib/color_field/color_field.install).
Warning: foreach() argument must be of type array|object, null given in color_field_requirements() (line 49 of /sites/all/modules/contrib/color_field/color_field.install).
Warning: Trying to access array offset on value of type bool in color_field_requirements() (line 67 of /sites/all/modules/contrib/color_field/color_field.install).
Warning: Trying to access array offset on value of type bool in color_field_requirements() (line 68 of /sites/all/modules/contrib/color_field/color_field.install).
Starting on line 44 of color_field.install
Replace with the following:
function color_field_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
$t = get_t();
$color_field_library = drupal_get_library('color_field', 'jquery-simple-color');
// Check if $color_field_library is an array and has the expected keys
if (
is_array($color_field_library)
&& isset($color_field_library['title'])
&& isset($color_field_library['version'])
&& isset($color_field_library['website'])
) {
// Check if 'js' key exists and its value is an array
if (isset($color_field_library['js']) && is_array($color_field_library['js'])) {
foreach ($color_field_library['js'] as $path => $js) {
if (!file_exists($path)) {
$requirements['jquery-simple-color'] = [
'severity' => REQUIREMENT_WARNING,
'title' => $t('Color Field (jquery simple color)'),
'value' => $t('Missing'),
'description' => $t('The jquery simple color library isn\'t available so this Color Field Module will not support the jQuery Simple Color widget. Please download the plugin (%version) from !website.', [
'!website' => l($color_field_library['website'], $color_field_library['website']),
'%version' => $color_field_library['version'],
]),
];
break;
}
}
}
// Check if 'jquery-simple-color' is not set in $requirements
if (!isset($requirements['jquery-simple-color'])) {
$requirements['jquery-simple-color'] = [
'severity' => REQUIREMENT_OK,
'title' => $color_field_library['title'],
'value' => $color_field_library['version'],
];
}
}
}
return $requirements;
}
Disclaimer: Generated with Google Gemini