From 3b21346937cb48e54bfd280984c12399dfe54d95 Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Fri, 12 Apr 2024 12:35:18 -0700 Subject: [PATCH] Remove data_table from existing plan_record entity type definition #829 --- CHANGELOG.md | 4 ++++ modules/core/plan/plan.post_update.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 104f099ecc..b31dcbc7e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- [Remove data_table from existing plan_record entity type definition #829](https://github.com/farmOS/farmOS/pull/829) + ## [3.2.1] 2024-04-12 ### Fixed diff --git a/modules/core/plan/plan.post_update.php b/modules/core/plan/plan.post_update.php index 72baf6e9e4..8116431b48 100644 --- a/modules/core/plan/plan.post_update.php +++ b/modules/core/plan/plan.post_update.php @@ -16,3 +16,22 @@ function plan_post_update_install_plan_record(&$sandbox) { \Drupal::entityTypeManager()->getDefinition('plan_record') ); } + +/** + * Remove the plan_record data_table attribute. + */ +function plan_post_update_remove_plan_record_data_table(&$sandbox) { + + // Load existing plan_record entity type and remove the data_table attribute. + $update_manager = \Drupal::entityDefinitionUpdateManager(); + $plan_record = $update_manager->getEntityType('plan_record'); + $plan_record->set('data_table', NULL); + + // Get the existing field storage definitions. This is a required parameter + // for EntityDefinitionUpdateManagerInterface::updateFieldableEntityType. + // We cannot use EntityDefinitionUpdateManagerInterface::updateEntityType. + $field_storage_definitions = \Drupal::service('entity.last_installed_schema.repository')->getLastInstalledFieldStorageDefinitions('plan_record'); + + // Update the entity type. + $update_manager->updateFieldableEntityType($plan_record, $field_storage_definitions, $sandbox); +}