Unable to edit existing extra field or render any public site pages

Created on 11 April 2024, 2 months ago
Updated 18 June 2024, 6 days ago

Problem/Motivation

I've just updated to v2.1.0-rc1, on a site running Drupal 9.5.11 using PHP 8.1.27. When trying to view any public page, or manage existing extra fields on a content type (bundle) using /admin/structure/types/manage/book/extra-fields, the page doesn't load. This works fine using v2.0.0-alpha5. The following is logged:

Warning: Undefined array key "entity_extra_field.book.reading_order_pager" in Drupal\Core\Config\Entity\ConfigEntityStorage->doLoadMultiple() (line 202 of /public_html/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php)
#0 /public_html/core/includes/bootstrap.inc(347): _drupal_error_handler_real(2, 'Undefined array...', '/home/customer/...', 202)
#1 /public_html/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(202): _drupal_error_handler(2, 'Undefined array...', '/home/customer/...', 202)
#2 /public_html/core/lib/Drupal/Core/Entity/EntityStorageBase.php(346): Drupal\Core\Config\Entity\ConfigEntityStorage->doLoadMultiple(Array)
#3 /public_html/core/lib/Drupal/Core/Entity/EntityListBuilder.php(87): Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array)
#4 /public_html/core/lib/Drupal/Core/Entity/EntityListBuilder.php(218): Drupal\Core\Entity\EntityListBuilder->load()
#5 /public_html/core/lib/Drupal/Core/Entity/Controller/EntityListController.php(23): Drupal\Core\Entity\EntityListBuilder->render()
#6 [internal function]: Drupal\Core\Entity\Controller\EntityListController->listing('entity_extra_fi...')
#7 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#8 /public_html/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#10 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#11 /vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#13 /public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /public_html/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#22 {main}
Error: Call to a member function getName() on null in Drupal\Core\Config\Entity\ConfigEntityStorage->doLoadMultiple() (line 202 of /public_html/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php)
#0 /public_html/core/lib/Drupal/Core/Entity/EntityStorageBase.php(346): Drupal\Core\Config\Entity\ConfigEntityStorage->doLoadMultiple(Array)
#1 /public_html/core/lib/Drupal/Core/Entity/EntityListBuilder.php(87): Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array)

Etc.

πŸ› Bug report
Status

RTBC

Version

2.1

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom natts London

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

Merge Requests

Comments & Activities

  • Issue created by @natts
  • πŸ‡ΊπŸ‡ΈUnited States capellic Austin, Texas

    Same issue here.

  • πŸ‡ΊπŸ‡ΈUnited States pdxclankeith

    Ran into the getName() null error on Drupal 10.2.5 after upgrading to 2.1.0-rc1.

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    This is a regress from this issue πŸ› Unable to create extra field on user entity Fixed

    That changes the ID of the config - but there is no update hook provided to fix existing config.

    What is happening is that the the config storage loads all the configs which are keyed by the old id:

        foreach ($this->configFactory->loadMultiple($names) as $config) {
          $id = $config->get($this->idKey);
          $records[$id] = $this->overrideFree ? $config->getOriginal(NULL, FALSE) : $config->get();
          $configs[$id] = $config;
        }
        $entities = $this->mapFromStorageRecords($records);
    

    When it loops through the entities returned, they have the key id, so this thows an exception as $configs[$id] isn't set - configs is keyed by the old id.

        foreach ($entities as $id => $entity) {
          $self_referring_cache_tag = ['config:' . $configs[$id]->getName()];

    This module needs an update hook to fix the old configs.

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    Opened MR to revert the change which I believe is accidental.

    This will still need an update hook I believe, as this will cause the same issue for people who have created config from 2.1.0-rc1 or when using the committed diff as a patch (as indicated in the related issue, some people are using the committed change already having updated the config ids themselves).

    Setting needs work as I think with or without the id revert this will need an update hook to ensure what is in configuration matches what the entity generates for its id.

  • Status changed to Needs work 2 months ago
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith
  • Status changed to Needs review 2 months ago
  • Hello,
    After installing the module, the two errors are occurring, one is while creating a new extra field and another is when editing the existing extra field.
    ERRORS:
    1. Error: Typed property Drupal\entity_extra_field\Entity\EntityExtraField::$name must not be accessed before initialization
    2. Error: Call to a member function getName() on null

    Solution:
    To resolve above two errors, created a patch. Please review the attached patch file.
    Thank you!

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    Hi arora.shivani,

    There is a different issue reported in πŸ› Unable to add an extra field on a content type/bundle that has no extra fields already Active which is specific to your first issue.

    There is already a patch in that issue that is the same as yours so it looks like that is another valid fix that needs to go in but this issue is about existing data not fresh installs.

    Please do follow up in that related issue that the patch works for you.

    Setting back to needs work based on my previous comment / MR.

  • Status changed to Needs work 2 months ago
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith
  • Status changed to Needs review 2 months ago
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    @arora.shivani - I took a look and the patch doesn't do anything for the errors reported specifically in this issue - I think my original comment stands that your issue is likely in πŸ› Unable to add an extra field on a content type/bundle that has no extra fields already Active

    Added an update hook to correct any broken config.

    This I think can be used for either case if the id change is reverted or not.

    It will help people who have either created config using the changed id format - or if the id format is not going to change back it will convert old config to the new format.

    The new format is I think a mistake, if you have the same bundle name across multiple entity types (rare but possible) this could lead to collision, I believe it was just a mistake that can be reverted.

  • πŸ‡¬πŸ‡§United Kingdom hoegrammer

    The MR worked for me, thanks

  • Status changed to RTBC 28 days ago
  • πŸ‡ΊπŸ‡ΈUnited States COBadger

    Marking MR15 as RTBC.

  • πŸ‡§πŸ‡ͺBelgium Vacilando Brussels

    #11 worked for me as well. Could this please be committed to dev at least?

Production build 0.69.0 2024