Cron error due to imcomplete deleted entity

Created on 20 June 2024, 8 days ago

Problem/Motivation

Here's a bug that's preventing cron running for me, due to a deleted site setting type, that seems to have been deleting before field_purge_batch was run.

Error: Call to a member function get() on null in /var/www/html/web/modules/contrib/site_settings/src/Entity/SiteSettingEntity.php on line 344 #0 [internal function]: Drupal\site_settings\Entity\SiteSettingEntity::getDefaultFieldset(Object(Drupal\site_settings\Entity\SiteSettingEntity), Object(Drupal\Core\Field\BaseFieldDefinition))
#1 /var/www/html/web/core/lib/Drupal/Core/Field/BaseFieldDefinition.php(442): call_user_func('Drupal\\site_set...', Object(Drupal\site_settings\Entity\SiteSettingEntity), Object(Drupal\Core\Field\BaseFieldDefinition))
#2 /var/www/html/web/core/lib/Drupal/Core/Field/FieldItemList.php(169): Drupal\Core\Field\BaseFieldDefinition->getDefaultValue(Object(Drupal\site_settings\Entity\SiteSettingEntity))
#3 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(271): Drupal\Core\Field\FieldItemList->applyDefaultValue()
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(129): Drupal\Core\Entity\ContentEntityStorageBase->initFieldValues(Object(Drupal\site_settings\Entity\SiteSettingEntity), Array)
#5 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(94): Drupal\Core\Entity\ContentEntityStorageBase->doCreate(Array)
#6 /var/www/html/web/core/modules/field/field.module(288): Drupal\Core\Entity\ContentEntityStorageBase->create(Array)
#7 /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(1685): _field_create_entity_from_ids(Object(stdClass))
#8 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(557): Drupal\Core\Entity\Sql\SqlContentEntityStorage->readFieldItemsToPurge(Object(Drupal\field\Entity\FieldConfig), 50)
#9 /var/www/html/web/core/modules/field/field.purge.inc(83): Drupal\Core\Entity\ContentEntityStorageBase->purgeFieldData(Object(Drupal\field\Entity\FieldConfig), 50)
#10 /var/www/html/web/core/modules/field/field.module(169): field_purge_batch(50)
#11 /var/www/html/web/core/lib/Drupal/Core/Cron.php(335): field_cron()

It looks like field_purge_batch is trying to remove fields from an entity type that no longer exists.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States oknate Greater New York City Area

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

Comments & Activities

  • Issue created by @oknate
  • πŸ‡ΊπŸ‡ΈUnited States oknate Greater New York City Area

    Here's a patch that fixes this bug and lets cron run.

  • Status changed to Needs review 8 days ago
  • πŸ‡ΊπŸ‡ΈUnited States oknate Greater New York City Area
  • πŸ‡ΊπŸ‡ΈUnited States oknate Greater New York City Area

    Marking ready for review. I don't know if anyone else has this problem, nor how to reproduce.

    We removed a site setting type and it wasn't fully cleaned up.

  • πŸ‡ΊπŸ‡ΈUnited States oknate Greater New York City Area
  • Status changed to Needs work 8 days ago
  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    Thanks for flagging! Can you create a merge request with your patch please so tests run/coding standards run/etc? Thanks!

Production build 0.69.0 2024