From 416ac0c5e175fc2586d5ee0676c61da02c8184b9 Mon Sep 17 00:00:00 2001 From: webchick Date: Sat, 13 Oct 2012 21:25:56 -0700 Subject: [PATCH] Issue #1798760 by ACF, alexpott: Convert menu_masks() to the state system. --- core/includes/menu.inc | 10 +++++----- .../system/lib/Drupal/system/Tests/Menu/RouterTest.php | 2 +- core/modules/system/system.install | 8 ++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 112e4f56bc1..5a5e5443de4 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -319,10 +319,10 @@ function menu_get_ancestors($parts) { $ancestors = array(); $length = $number_parts - 1; $end = (1 << $number_parts) - 1; - $masks = variable_get('menu_masks'); - // If the optimized menu_masks array is not available use brute force to get + $masks = state()->get('menu.masks'); + // If the optimized menu.masks array is not available use brute force to get // the correct $ancestors and $placeholders returned. Do not use this as the - // default value of the menu_masks variable to avoid building such a big + // default value of the menu.masks variable to avoid building such a big // array. if (!$masks) { $masks = range(511, 1); @@ -453,7 +453,7 @@ function menu_get_item($path = NULL, $router_item = NULL) { if (!isset($router_items[$path])) { // Rebuild if we know it's needed, or if the menu masks are missing which // occurs rarely, likely due to a race condition of multiple rebuilds. - if (state()->get('menu_rebuild_needed') || !variable_get('menu_masks', array())) { + if (state()->get('menu_rebuild_needed') || !state()->get('menu.masks')) { menu_router_rebuild(); } $original_map = arg(NULL, $path); @@ -3784,7 +3784,7 @@ function _menu_router_save($menu, $masks) { // Insert any remaining records. $insert->execute(); // Store the masks. - variable_set('menu_masks', $masks); + state()->set('menu.masks', $masks); return $menu; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php index 8af163ff331..094961cbc68 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/RouterTest.php @@ -423,7 +423,7 @@ class RouterTest extends WebTestBase { * Test menu_get_item() with empty ancestors. */ function testMenuGetItemNoAncestors() { - variable_set('menu_masks', array()); + state()->set('menu.masks', array()); $this->drupalGet(''); } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index b1cf3750173..49103900b93 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2154,6 +2154,14 @@ function system_update_8027() { update_variable_del('javascript_parsed'); } +/** + * Remove the 'menu_masks' configuration variable. + */ +function system_update_8028() { + // No upgrade path needed since the menu router will be rebuilt during d7 to d8 upgrade. + update_variable_del('menu_masks'); +} + /** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000.