diff --git a/profiles/wcm_base/CHANGELOG.txt b/profiles/wcm_base/CHANGELOG.txt index 32c08e0dc62749ee25af566180f2863a1f6ba2b5..badb66912227a0970228382f2ab76b1df6be0f2e 100644 --- a/profiles/wcm_base/CHANGELOG.txt +++ b/profiles/wcm_base/CHANGELOG.txt @@ -1,3 +1,7 @@ +WCM Base 7.x-1.8-rc1, 2018-05-31 +-------------------------------- +- WCM Base: Added patch to rebuild Menu Block IDs on cache clear. + WCM Base 7.x-1.7, 2018-05-30 ---------------------------- - WCM Base: Patched Menu Block module to allow custom delta values. diff --git a/profiles/wcm_base/modules/contrib/menu_block/PATCHES.txt b/profiles/wcm_base/modules/contrib/menu_block/PATCHES.txt index 630faf808ccc26537f6e92b9e9c0129f2e914553..2310c258f06b71f5df4cc6a3ac3e2a2fa078bc80 100644 --- a/profiles/wcm_base/modules/contrib/menu_block/PATCHES.txt +++ b/profiles/wcm_base/modules/contrib/menu_block/PATCHES.txt @@ -1,4 +1,5 @@ The following patches have been applied to this project: - http://drupal.org/files/issues/2018-05-14/menu_block-customize_deltas-2076119-7.patch +- http://drupal.org/files/issues/2018-06-01/menu_block-rebuild-block-ids-2932156-5.patch This file was automatically generated by Drush Make (http://drupal.org/project/drush). diff --git a/profiles/wcm_base/modules/contrib/menu_block/menu_block.module b/profiles/wcm_base/modules/contrib/menu_block/menu_block.module index a5bf3964f52587ca3a77b7dd6cc7fe73d5739674..425338155a55145026f2c4a301b96d362c6fd664 100644 --- a/profiles/wcm_base/modules/contrib/menu_block/menu_block.module +++ b/profiles/wcm_base/modules/contrib/menu_block/menu_block.module @@ -1070,3 +1070,44 @@ function menu_block_menu_link_update($link) { function menu_block_menu_link_delete($link) { menu_block_menu_link_insert($link); } + +/** + * Implements hook_flush_caches(). + * + * Tell Drupal to execute callback that rebuilds menu_block_ids variable. + */ +function menu_block_flush_caches() { + register_shutdown_function('menu_block_rebuild_block_ids'); + return array(); +} + +/** + * Rebuild menu_block_ids from existing menu_block delta values in block table. + */ +function menu_block_rebuild_block_ids() { + $existing = variable_get('menu_block_ids', array()); + // exclude non-numeric delta values (eg menu blocks exported into Features modules) + $new = array(); + $result = db_query('select distinct delta from block where module = :module and delta is not null', array(':module' => 'menu_block')); + if ($result) { + foreach ($result as $row) { + $id = $row->delta; + if ($id) { + $new[] = $id; + } + } + } + sort($new); + if ($new != $existing) { + $missing = array_diff($existing, $new); + if ($missing) { + watchdog('menu_block', 'Removing obsolete block IDs from menu_block_ids variable: !list', array('!list' => implode(',', $missing))); + } + $additions = array_diff($new, $existing); + if ($additions) { + watchdog('menu_block', 'Adding missing block IDs to menu_block_ids variable: !list', array('!list' => implode(',', $additions))); + } + variable_set('menu_block_ids', $new); + } +} + diff --git a/profiles/wcm_base/wcm_base.make b/profiles/wcm_base/wcm_base.make index 866e83b7cdcd0391fdb9fdb7c578e62e9d104ece..55edd9dc00e19e8fddf4c00b0dca28757f2930d2 100644 --- a/profiles/wcm_base/wcm_base.make +++ b/profiles/wcm_base/wcm_base.make @@ -82,6 +82,7 @@ projects[mailsystem][subdir] = contrib projects[menu_block][version] = 2.7 projects[menu_block][subdir] = contrib projects[menu_block][patch][2076119] = http://drupal.org/files/issues/2018-05-14/menu_block-customize_deltas-2076119-7.patch +projects[menu_block][patch][2932156] = http://drupal.org/files/issues/2018-06-01/menu_block-rebuild-block-ids-2932156-5.patch projects[migrate][version] = 2.8 projects[migrate][subdir] = contrib