Problem/Motivation

After updating all drupal modules in a website that already had colorapi and jquery_colorpicker enabled, and already had a color field with the jquery_colorpicker widget, editing or creating nodes with a color field now throw this error:
Notice: Undefined index: name in Drupal\colorapi\Plugin\Field\FieldType\ColorItem->setValue() (line 85 of modules/contrib/colorapi/src/Plugin/Field/FieldType/ColorItem.php).

Steps to reproduce

somehow have a website with a node type with a color field, created with a previous version of colorapi and jquery_colorpicker.
Then update all modules and run updb and add or edit a node that has a color field. It is not even necessary to have the field widget set to jquery_colorpicker, just having the widget set to 'Textfield Input' also generates the same error

Proposed resolution

- Edit colorapi/src/Plugin/Field/FieldType/ColorItem.php
- Add new line inside function setValue (line 90) to check if $values['name'] exists:
$values['name'] = isset($values['name']) ? $values['name'] : '';

Remaining tasks

- someone else confirms bug (had it myself in 3 different projects)
- create/test patch
- commit patch
- or just immediatly add the line above in code in a newer version of the module

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

flyke created an issue. See original summary.

flyke’s picture

Issue summary: View changes
flyke’s picture

Neslee Canil Pinto’s picture

Status: Active » Needs review
FileSize
674 bytes

Status: Needs review » Needs work

The last submitted patch, 4: 3175130-4.patch, failed testing. View results

Neslee Canil Pinto’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.