Encountering Error with Opigno Statistics Module Version 3.1.0 Due to Color Module Dependency
Hello,
I am currently using the Opigno Statistics module version 3.1.0 in my Drupal 9 setup with an Opigno distribution. I have encountered the following error:
Warning: Trying to access array offset on value of type null in Drupal\color\ColorThemeDecorator->getPalette() (line 411 of modules/contrib/color/src/ColorThemeDecorator.php).
The issue seems to be related to the Color module, which is required by the Opigno distribution but not actively used in my theme (s_5_university). I am using a CSS file to manually color my website. (I believe I am using something that is referred to as subtheming)
I created a color settings file (
s_5_university.settings.yml
) for my theme, specifying some default colors, and declared support for the Color module in my theme's.info.yml
file. However, this did not resolve the issue, and the error persists.I understand that there is a patch under review for this issue. I would greatly appreciate it if you could expedite the review process, or suggest any other workaround that could help me resolve this issue.
Thank you for your assistance.
I have a Drupal 9 website with an Opigno distribution. Opigno uses Aristotle as their base theme. I created a subtheme called s_5_university that is the default for the website. This unfortunately messes with the Color module that Opigno requires for some of their functionality. We get the following error:
Warning: Trying to access array offset on value of type null in Drupal\color\ColorThemeDecorator->getPalette() (line 413 of modules/contrib/color/src/ColorThemeDecorator.php).This is because the getPalette function is passed the s_5_university value for the argument $theme here:
public function getPalette($theme, $default = FALSE) {And immediately tries to pass that value to the function color_get_info() here:
$info = color_get_info($theme);The color_get_info looks like the following:
/**
* Retrieves the Color module information for a particular theme.
*/
function color_get_info($theme) {
static $theme_info = [];if (isset($theme_info[$theme])) {
return $theme_info[$theme];
}$path = \Drupal::service('extension.list.theme')->getPath($theme);
$file = \Drupal::root() . '/' . $path . '/color/color.inc';
if ($path && file_exists($file)) {
include $file;
// Add in default values.
$info += [
// CSS files (excluding @import) to rewrite with new color scheme.
'css' => [],
// Files to copy.
'copy' => [],
// Gradient definitions.
'gradients' => [],
// Color areas to fill (x, y, width, height).
'fill' => [],
// Coordinates of all the theme slices (x, y, width, height) with their
// filename as used in the stylesheet.
'slices' => [],
// Reference color used for blending.
'blend_target' => '#ffffff',
];
$theme_info[$theme] = $info;
return $info;
}
}Now I haven't set up any Color module information for my theme s_5_university, and I am not sure exactly what I need to create to feed this function what it needs. It is likely encountering this error because I have no Color module information set up for it to read at this time.
Resolved
The color_get_info() function is looking for for a color directory with the color.inc file.
- In the subtheme directory create a directory called "color".
- In the subtheme directory go into the new directory "color" and create a file named "color.inc"
- In the subtheme directory go into the new directory "color" and create a file named "color.css"
- For reference of how these files should look, you can go to /themes/contrib/aristotle/color
This completely resolved my issue as now the color_get_info() function can access the information it is requesting.
- Status changed to Needs work
about 1 year ago 6:05pm 9 November 2023 - πΊπΈUnited States jcandan
Not resolved. But the above solution is a valid work around.
This issue's premise is sound. This module should not have a hard dependency on the Color module, since an Aristotle sub-theme or other custom theme may opt to not utilize this feature. Additionally, the color module is deprecated in Drupal core as of 9.4, and is removed in Drupal 10. Support for this module is carried via the new contrib module.
Patch #5 successfully applies, but the
Trying to access array offset on value of type null in Drupal\color\ColorThemeDecorator->getPalette()
warning persists. I believe we'll need a$palette = \Drupal::service('color.theme_decorator')->getPalette($theme);