Commit 86ef4929 authored by Dries's avatar Dries

Issue #1829308 by aspilicious: Convert variables in menu.inc to config and state.

parent 7bd2274b
......@@ -1254,9 +1254,9 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
}
$parents = $active_trail;
$expanded = variable_get('menu_expanded', array());
$expanded = state()->get('menu_expanded');
// Check whether the current menu has any links set to be expanded.
if (!$only_active_trail && in_array($menu_name, $expanded)) {
if (!$only_active_trail && $expanded && in_array($menu_name, $expanded)) {
// Collect all the links set to be expanded, and then add all of
// their children to the list as well.
do {
......@@ -2264,10 +2264,11 @@ function theme_menu_local_tasks(&$variables) {
*
* @return
* An array of menu machine names, in order of preference. The
* 'menu_default_active_menus' variable may be used to assert a menu order
* different from the order of creation, or to prevent a particular menu from
* being used at all in the active trail.
* E.g., $conf['menu_default_active_menus'] = array('tools', 'main')
* 'system.menu.active_menus_default' config item may be used to assert a menu
* order different from the order of creation, or to prevent a particular menu
* from being used at all in the active trail.
* E.g., $conf['system.menu']['active_menus_default'] = array('tools',
* 'main').
*/
function menu_set_active_menu_names($menu_names = NULL) {
$active = &drupal_static(__FUNCTION__);
......@@ -2276,7 +2277,8 @@ function menu_set_active_menu_names($menu_names = NULL) {
$active = $menu_names;
}
elseif (!isset($active)) {
$active = variable_get('menu_default_active_menus', array_keys(menu_list_system_menus()));
$config = config('system.menu');
$active = $config->get('active_menus_default') ?: array_keys(menu_list_system_menus());
}
return $active;
}
......@@ -3275,7 +3277,7 @@ function _menu_clear_page_cache() {
*/
function _menu_set_expanded_menus() {
$names = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name")->fetchCol();
variable_set('menu_expanded', $names);
state()->set('menu_expanded', $names);
}
/**
......
......@@ -274,11 +274,13 @@ function menu_save($menu) {
case SAVED_NEW:
// Make sure the menu is present in the active menus variable so that its
// items may appear in the menu active trail.
// @see menu_set_active_menu_names()
$active_menus = variable_get('menu_default_active_menus', array_keys(menu_get_menus()));
// See menu_set_active_menu_names().
$config = config('system.menu');
$active_menus = $config->get('active_menus_default') ?: array_keys(menu_get_menus());
if (!in_array($menu['menu_name'], $active_menus)) {
$active_menus[] = $menu['menu_name'];
variable_set('menu_default_active_menus', $active_menus);
$config->set('active_menus_default', $active_menus);
}
module_invoke_all('menu_insert', $menu);
......
......@@ -2202,6 +2202,17 @@ function system_update_8032() {
update_variable_del('drupal_js_cache_files');
}
/**
* Converts active_menus_default variable to config.
*
* @ingroup config_upgrade
*/
function system_update_8033() {
update_variables_to_config('system.menu', array(
'active_menus_default' => 'active_menus_default'
));
}
/**
* @} End of "defgroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment