- Issue created by @rahul.rahangdale
- Issue was unassigned.
Whenever trying to create a new entity wherever the Color API field is used, it throws the following PHP error:
Deprecated function: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\colorapi\Plugin\DataType\HexColorData->setValue() (line 26 of modules/contrib/colorapi/src/Plugin/DataType/HexColorData.php).
Drupal\colorapi\Plugin\DataType\HexColorData->setValue(NULL, ) (Line: 140)
Drupal\Core\TypedData\TypedData->applyDefaultValue() (Line: 242)
Drupal\Core\TypedData\Plugin\DataType\Map->applyDefaultValue() (Line: 242)
Drupal\Core\TypedData\Plugin\DataType\Map->applyDefaultValue() (Line: 178)
Drupal\Core\Field\FieldItemList->applyDefaultValue() (Line: 274)
Drupal\Core\Entity\ContentEntityStorageBase->initFieldValues(Object, Array) (Line: 129)
Drupal\Core\Entity\ContentEntityStorageBase->doCreate(Array) (Line: 94)
Drupal\Core\Entity\ContentEntityStorageBase->create(Array) (Line: 370)
Drupal\Core\Entity\EntityForm->getEntityFromRouteMatch(Object, 'node') (Line: 73)
Drupal\Core\Entity\HtmlEntityFormController->getFormObject(Object, 'node.default.default') (Line: 58)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 159)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
This error only occurs if you are running Drupal on PHP Version >= 8.1
Check if the field value is empty before passing it to strupper() function in the setValue method of the HexColorData.php file. Submitting the patch for the same.
Needs review
1.0
Code
The issue particularly affects sites running on PHP version 8.1.0 or later.