From 9920416fcc57c4f162df11a041681c5032c39f99 Mon Sep 17 00:00:00 2001 From: Steve Wirt Date: Wed, 31 Jan 2024 17:01:51 -0500 Subject: [PATCH] VACMS-15559 Programatically shut off queue checks and processing. --- .../custom/va_gov_vamc/va_gov_vamc.deploy.php | 4 +++- scripts/content/script-library.php | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/docroot/modules/custom/va_gov_vamc/va_gov_vamc.deploy.php b/docroot/modules/custom/va_gov_vamc/va_gov_vamc.deploy.php index 27dcdb93da..9c72b7bf41 100644 --- a/docroot/modules/custom/va_gov_vamc/va_gov_vamc.deploy.php +++ b/docroot/modules/custom/va_gov_vamc/va_gov_vamc.deploy.php @@ -23,14 +23,16 @@ function va_gov_vamc_deploy_build_va_police_9001(&$sandbox) { /** * Migrate some facility service data to service location paragraphs. */ -function va_gov_vamc_deploy_migrate_service_data_to_service_location_9002(&$sandbox) { +function va_gov_vamc_deploy_migrate_service_data_to_service_location_9003(&$sandbox) { $source_bundle = 'health_care_local_health_service'; script_library_sandbox_init($sandbox, 'get_nids_of_type', [$source_bundle, FALSE]); + script_library_toggle_post_api_queueing(TRUE); new ServiceLocationMigration($sandbox); $new_service_locations = $sandbox['service_locations_created_count'] ?? 0; $updated_service_locations = $sandbox['service_locations_updated_count'] ?? 0; $forward_revisions = $sandbox['forward_revisions_count'] ?? 0; + script_library_toggle_post_api_queueing(FALSE); return script_library_sandbox_complete($sandbox, "migrated @total {$source_bundle} nodes into {$new_service_locations} new service_location paragraphs, and {$updated_service_locations} updated. Also updated {$forward_revisions} forward revisions."); } diff --git a/scripts/content/script-library.php b/scripts/content/script-library.php index 816cf8918d..d16260b10c 100644 --- a/scripts/content/script-library.php +++ b/scripts/content/script-library.php @@ -392,6 +392,26 @@ function script_libary_map_to_value(string|null $lookup, array $map, bool $stric } } +/** + * Turns on or off settings related to the post_api. + * + * @param bool $state + * TRUE to toggle the settings on, FALSE to toggle them off. + */ +function script_library_toggle_post_api_queueing(bool $state): void { + $state = ($state) ? 1 : 0; + $config_post_api = \Drupal::configFactory()->getEditable('post_api.settings'); + + $config_post_api->set('pause_cron_processing', $state) + // CONSIDER: The only time we would want to fully disable queueing is during + // a deploy when editors can not save anything. + // ->set('disable_queueing', $state) . + ->save(FALSE); + $config_va_gov_post_api = \Drupal::configFactory()->getEditable('va_gov_post_api.settings'); + $config_va_gov_post_api->set('bypass_data_check', $state) + ->save(FALSE); +} + /** * Callback function to concat node ids with string. *