function hook_post_update_NAME

Same name in other branches
  1. 9 core/lib/Drupal/Core/Extension/module.api.php \hook_post_update_NAME()
  2. 8.9.x core/lib/Drupal/Core/Extension/module.api.php \hook_post_update_NAME()
  3. 10 core/lib/Drupal/Core/Extension/module.api.php \hook_post_update_NAME()

Related topics

22 functions implement hook_post_update_NAME()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

block_post_update_make_weight_integer in core/modules/block/block.post_update.php
Ensures that all block weights are integers.
forum_post_update_recreate_forum_index_rows in core/modules/forum/forum.post_update.php
Repopulate the forum index table.
media_post_update_media_author_views_filter_update in core/modules/media/media.post_update.php
Empty update function to clear the Views data cache.
module_test_post_update_test in core/modules/system/tests/modules/module_test/module_test.post_update.php
Test post update function.
navigation_post_update_navigation_user_links_menu in core/modules/navigation/navigation.post_update.php
Creates the Navigation user links menu.

... See full list

File

core/lib/Drupal/Core/Extension/module.api.php, line 892

Code

function hook_post_update_NAME(&$sandbox) {
    // Example of updating some content.
    $node = \Drupal\node\Entity\Node::load(123);
    $node->setTitle('foo');
    $node->save();
    $result = t('Node %nid saved', [
        '%nid' => $node->id(),
    ]);
    // Example of updating some config.
    if (\Drupal::moduleHandler()->moduleExists('taxonomy')) {
        // Update the dependencies of all Vocabulary configuration entities.
        \Drupal::classResolver(\Drupal\Core\Config\Entity\ConfigEntityUpdater::class)->update($sandbox, 'taxonomy_vocabulary');
    }
    return $result;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.