Warning: Trying to access array offset on value of type int in image_field_config_delete()

Created on 13 August 2024, 6 months ago

Problem/Motivation

D10.3.1, PHP 8.2.19. Deleting a field of type file:image (not media:image) from a content type gave me this warning (and then a confirmation that the field had been deleted, which it had):

Warning: Trying to access array offset on value of type int in image_field_config_delete() (line 503 of core/modules/image/image.module).
image_field_config_delete(Object)
call_user_func_array(Object, Array) (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'image') (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('field_config_delete', Object) (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll('field_config_delete', Array) (Line: 341)
Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook('delete', Object) (Line: 462)
Drupal\Core\Entity\EntityStorageBase->delete(Array) (Line: 362)
Drupal\Core\Entity\EntityBase->delete() (Line: 120)
Drupal\field_ui\Form\FieldConfigDeleteForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 67)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('field_config_delete_form', Array, Object) (Line: 326)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->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: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  1. Install D10.3.1 on PHP 8.2.19
  2. create a content type, add an optional field of type file:image (not the media:image)
  3. create some nodes, populate some (but not all) nodes with images
  4. Attempt to delete the image field from the content type created using the UI (ex: /site/admin/structure/types/manage/article/fields/node.article.field_image/delete)
  5. Verify error message above.

Proposed resolution

Been seeing this a lot since upgrading to PHP8.2 from 8.1. I assume we just need to check what is giving an int instead of an array.

Remaining tasks

Fix the issue 8-)

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

Fixed warning that occurs when deleting an image field from an entity.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
Image systemΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΊπŸ‡ΈUnited States josephcheek Provo, UT

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024