diff --git a/uw_cfg_common.install b/uw_cfg_common.install index 62764f3619bc310f5b38d94786b3c08525cb94db..7062b8b2f9fb4e0507cf010daf56de28b406b1fa 100644 --- a/uw_cfg_common.install +++ b/uw_cfg_common.install @@ -242,22 +242,24 @@ function _uw_cfg_common_create_term($taxonomy_name, $vocab_machine_name, $weight } /** - * Set default settings for listing page blocks. + * For listing page blocks items per page, when default settings were used, + * change to the original default number of items. */ function uw_cfg_common_update_8101() { - // Block ids that need to be changed. + // Block ids that need to be changed, and what the original default was. + // For some reason, we didn't originally use the same number for everything. $block_ids = [ - 'views_block:uw_view_blogs-blogs_listing_block', - 'views_block:uw_view_events-events_listing_block', - 'views_block:uw_view_news_items-news_items_listing_block', + 'views_block:uw_view_blogs-blogs_listing_block' => 5, + 'views_block:uw_view_events-events_listing_block' => 10, + 'views_block:uw_view_news_items-news_items_listing_block' => 10, ]; // Load all the nodes. $nodes = Node::loadMultiple(); - // Step through each node and set the default setting - // to 3 on listing blocks. + // Step through each node and set any that were using the default setting + // to the number that was the default before this change. foreach ($nodes as $node) { // Flag to save the node, have this to save processing @@ -279,19 +281,16 @@ function uw_cfg_common_update_8101() { // If this component is one that needs to be changed, // then check for setting and change if required. - if (in_array($component->getPluginId(), $block_ids)) { + if (in_array($component->getPluginId(), array_keys($block_ids))) { // Load the config for the block. $configurations = $component->get('configuration'); - // If the config is none of 5, it needs to be changed to 3. - if ( - $configurations['items_per_page'] == 'none' || - $configurations['items_per_page'] == '5' - ) { - + // If the config is set to "none", it needs to be changed to + // be set to the number that was the old default value. + if ($configurations['items_per_page'] == 'none') { // Change the config and save the component. - $configurations['items_per_page'] = '3'; + $configurations['items_per_page'] = $block_ids[$component->getPluginId()]; $component->setConfiguration($configurations); // Set the save node flag so that we know to