1 system.install system_update_1096()

Fix icon display for customized system menu items.

Related topics

File

core/modules/system/system.install, line 3588
Install, update and uninstall functions for the system module.

Code

function system_update_1096() {
  $icon_mapping = array(
    'admin/dashboard' => 'speedometer-fill',
    'admin/content' => 'pencil-fill',
    'admin/people' => 'users-fill',
    'admin/appearance' => 'palette-fill',
    'admin/modules' => 'puzzle-piece-fill',
    'admin/structure' => 'stack-fill',
    'admin/config' => 'gear-fill',
    'admin/reports' => 'info-fill',
  );

  $items = db_select('menu_links')
    ->fields('menu_links')
    ->condition('menu_name', 'management')
    ->condition('module', 'system')
    ->condition('depth', 2)
    ->condition('customized', 1)
    ->execute()->fetchAllAssoc('router_path');

  foreach ($items as $router_path => $item) {
    if (!array_key_exists($router_path, $icon_mapping)) {
      continue;
    }
    $existing_item = (array) $item;
    $options = unserialize($existing_item['options']);
    if (isset($options['icon'])) {
      continue;
    }
    $updated_item = $existing_item;
    $options['icon'] = $icon_mapping[$router_path];
    $updated_item['options'] = $options;
    menu_link_save($updated_item, $existing_item);
  }
}