Post update hooks
Partly due to the weak configuration management system in versions of Drupal (7 and before), the update hooks we just talked about have evolved—through developer creativity—into a mechanism for updating various types of configuration or performing tasks (even content-related) upon deployment to the next environment. Helping out with this is the $sandbox
argument passed to the hook implementations, which can be used to batch these operations (to prevent an execution timeout). We will not cover the batching aspect here but rather as part of the standalone Batch API chapter.
Since Drupal 8, we no longer have to misuse the update hooks for performing tasks that are not strictly related to updating schemas: be that our own custom table schemas or content entity ones. Instead, we can use hook_post_update_NAME()
.
Post update hooks are fired after update hooks have run and we are sure all the database tables have been brought to their correct state. They...