X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Fsystem.post_update.php;h=ba8e798ca1536532aed80516aad10466852e7dd0;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=36039dff0d3bddb0a41f6569cde15ed978ec46e8;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/web/core/modules/system/system.post_update.php b/web/core/modules/system/system.post_update.php index 36039dff0..ba8e798ca 100644 --- a/web/core/modules/system/system.post_update.php +++ b/web/core/modules/system/system.post_update.php @@ -5,7 +5,9 @@ * Post update functions for System. */ +use Drupal\Core\Config\Entity\ConfigEntityUpdater; use Drupal\Core\Entity\Display\EntityDisplayInterface; +use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\Entity\EntityFormDisplay; use Drupal\Core\Entity\Entity\EntityViewDisplay; @@ -49,7 +51,6 @@ function system_post_update_add_region_to_entity_displays() { array_map($entity_save, EntityFormDisplay::loadMultiple()); } - /** * Force caches using hashes to be cleared (Twig, render cache, etc.). */ @@ -81,3 +82,99 @@ function system_post_update_classy_message_library() { function system_post_update_field_type_plugins() { // Empty post-update hook. } + +/** + * Clear caches due to schema changes in core.entity.schema.yml. + */ +function system_post_update_field_formatter_entity_schema() { + // Empty post-update hook. +} + +/** + * Change plugin IDs of actions. + */ +function system_post_update_change_action_plugins() { + $old_new_action_id_map = [ + 'comment_publish_action' => 'entity:publish_action:comment', + 'comment_unpublish_action' => 'entity:unpublish_action:comment', + 'comment_save_action' => 'entity:save_action:comment', + 'node_publish_action' => 'entity:publish_action:node', + 'node_unpublish_action' => 'entity:unpublish_action:node', + 'node_save_action' => 'entity:save_action:node', + ]; + + /** @var \Drupal\system\Entity\Action[] $actions */ + $actions = \Drupal::entityTypeManager()->getStorage('action')->loadMultiple(); + foreach ($actions as $action) { + if (isset($old_new_action_id_map[$action->getPlugin()->getPluginId()])) { + $action->setPlugin($old_new_action_id_map[$action->getPlugin()->getPluginId()]); + $action->save(); + } + } +} + +/** + * Change plugin IDs of delete actions. + */ +function system_post_update_change_delete_action_plugins() { + $old_new_action_id_map = [ + 'comment_delete_action' => 'entity:delete_action:comment', + 'node_delete_action' => 'entity:delete_action:node', + ]; + + /** @var \Drupal\system\Entity\Action[] $actions */ + $actions = \Drupal::entityTypeManager()->getStorage('action')->loadMultiple(); + foreach ($actions as $action) { + if (isset($old_new_action_id_map[$action->getPlugin()->getPluginId()])) { + $action->setPlugin($old_new_action_id_map[$action->getPlugin()->getPluginId()]); + $action->save(); + } + } +} + +/** + * Force cache clear for language item callback. + * + * @see https://www.drupal.org/node/2851736 + */ +function system_post_update_language_item_callback() { + // Empty post-update hook. +} + +/** + * Update all entity displays that contain extra fields. + */ +function system_post_update_extra_fields(&$sandbox = NULL) { + $config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class); + $entity_field_manager = \Drupal::service('entity_field.manager'); + + $callback = function (EntityDisplayInterface $display) use ($entity_field_manager) { + $display_context = $display instanceof EntityViewDisplayInterface ? 'display' : 'form'; + $extra_fields = $entity_field_manager->getExtraFields($display->getTargetEntityTypeId(), $display->getTargetBundle()); + + // If any extra fields are used as a component, resave the display with the + // updated component information. + $needs_save = FALSE; + if (!empty($extra_fields[$display_context])) { + foreach ($extra_fields[$display_context] as $name => $extra_field) { + if ($component = $display->getComponent($name)) { + $display->setComponent($name, $component); + $needs_save = TRUE; + } + } + } + return $needs_save; + }; + + $config_entity_updater->update($sandbox, 'entity_form_display', $callback); + $config_entity_updater->update($sandbox, 'entity_view_display', $callback); +} + +/** + * Force cache clear to ensure aggregated JavaScript files are regenerated. + * + * @see https://www.drupal.org/project/drupal/issues/2995570 + */ +function system_post_update_states_clear_cache() { + // Empty post-update hook. +}