Problem/Motivation

PHP errors occur when saving on the content type level. Also, the Custom Body Class Settings field is not rendered in the Node Edit screen.

Steps to reproduce

I am using Drupal 10.4.7 and Custom Body Class module 2.0.1. When I enter a value into the Custom Body Class Settings field on the content type level for any content type and save, the following PHP error occurs twice:

Warning: Trying to access array offset on value of type null in custom_body_class_node_special_character_form_validate() (line 118 of modules/contrib/custom_body_class/custom_body_class.module).
custom_body_class_node_special_character_form_validate()
call_user_func_array() (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers() (Line: 274)
Drupal\Core\Form\FormValidator->doValidateForm() (Line: 118)
Drupal\Core\Form\FormValidator->validateForm() (Line: 593)
Drupal\Core\Form\FormBuilder->processForm() (Line: 326)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 57)
Drupal\advban\AdvbanMiddleware->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Also, for one particular content type, the Custom Body Class Settings field is not rendered in the Node Edit screen. Here is a screenshot. For all other content types, the field renders correctly.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mvnovick created an issue. See original summary.

jatingupta40 made their first commit to this issue’s fork.

jatingupta40’s picture

Opened a MR.

juanyisus03’s picture

Hi!! The same happen to me, I,m using Drupal 10.5.6 and PHP version 8.1.27.

Came here to ask, How can be this issue a clone of itself @jatingupta40 ??

junaidpv changed the visibility of the branch 3524819-array-offset-on-value-of-type-null to hidden.

junaidpv changed the visibility of the branch 3524819-array-offset-on-value-of-type-null to active.

jatingupta40’s picture

Status: Active » Needs review
dubs’s picture

StatusFileSize
new968 bytes

The fork seems to be empty, so I've attached my version of the patch for this problem.