From c66f68bc8a8a7e3ba69b8b13cda304b2ac312a63 Mon Sep 17 00:00:00 2001
From: quietone <quietone@2572884.no-reply.drupal.org>
Date: Fri, 4 Feb 2022 00:53:07 +0000
Subject: [PATCH] Issue #3260765 by andypost, quietone, xjm: Remove deprecated
 code from menu-related subsystems

---
 core/includes/menu.inc                        | 34 ------------
 core/includes/theme.inc                       |  1 -
 core/lib/Drupal/Core/DrupalKernel.php         |  1 -
 .../modules/book/src/BookManagerInterface.php |  3 -
 core/modules/menu_ui/menu_ui.module           | 30 ----------
 .../KernelTests/Core/Menu/MenuLegacyTest.php  | 55 -------------------
 6 files changed, 124 deletions(-)
 delete mode 100644 core/includes/menu.inc
 delete mode 100644 core/tests/Drupal/KernelTests/Core/Menu/MenuLegacyTest.php

diff --git a/core/includes/menu.inc b/core/includes/menu.inc
deleted file mode 100644
index 11c9f0781649..000000000000
--- a/core/includes/menu.inc
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/**
- * @file
- * API for the Drupal menu system.
- */
-
-/**
- * @addtogroup menu
- * @{
- */
-
-/**
- * Returns an array containing the names of system-defined (default) menus.
- *
- * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
- *   \Drupal\system\Entity\Menu::loadMultiple() instead.
- *
- * @see https://www.drupal.org/node/3027453
- */
-function menu_list_system_menus() {
-  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\system\Entity\Menu::loadMultiple() instead. See https://www.drupal.org/node/3027453', E_USER_DEPRECATED);
-  return [
-    'tools' => 'Tools',
-    'admin' => 'Administration',
-    'account' => 'User account menu',
-    'main' => 'Main navigation',
-    'footer' => 'Footer menu',
-  ];
-}
-
-/**
- * @} End of "addtogroup menu".
- */
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index ff7052d4a8d8..3a2a964fb8ba 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2082,7 +2082,6 @@ function drupal_common_theme() {
     'pager' => [
       'render element' => 'pager',
     ],
-    // From menu.inc.
     'menu' => [
       'variables' => ['menu_name' => NULL, 'items' => [], 'attributes' => []],
     ],
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index e23d81b15636..59f24ed7e96b 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -537,7 +537,6 @@ public function loadLegacyIncludes() {
     require_once $this->root . '/core/includes/common.inc';
     require_once $this->root . '/core/includes/module.inc';
     require_once $this->root . '/core/includes/theme.inc';
-    require_once $this->root . '/core/includes/menu.inc';
     require_once $this->root . '/core/includes/form.inc';
     require_once $this->root . '/core/includes/errors.inc';
     require_once $this->root . '/core/includes/schema.inc';
diff --git a/core/modules/book/src/BookManagerInterface.php b/core/modules/book/src/BookManagerInterface.php
index 44107f2f9066..e6f9c6f55d5a 100644
--- a/core/modules/book/src/BookManagerInterface.php
+++ b/core/modules/book/src/BookManagerInterface.php
@@ -133,9 +133,6 @@ public function bookTreeCollectNodeLinks(&$tree, &$node_links);
   /**
    * Provides book loading, access control and translation.
    *
-   * Note: copied from _menu_link_translate() in menu.inc, but reduced to the
-   * minimal code that's used.
-   *
    * @param array $link
    *   A book link.
    */
diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
index ad49bf10f701..b3d620d54619 100644
--- a/core/modules/menu_ui/menu_ui.module
+++ b/core/modules/menu_ui/menu_ui.module
@@ -423,36 +423,6 @@ function menu_ui_form_node_type_form_builder($entity_type, NodeTypeInterface $ty
   $type->setThirdPartySetting('menu_ui', 'parent', $form_state->getValue('menu_parent'));
 }
 
-/**
- * Return an associative array of the custom menus names.
- *
- * @param bool $all
- *   (optional) If FALSE return only user-added menus, or if TRUE also include
- *   the menus defined by the system. Defaults to TRUE.
- *
- * @return array
- *   An array with the machine-readable names as the keys, and human-readable
- *   titles as the values.
- *
- * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
- *   \Drupal\system\Entity\Menu::loadMultiple() instead.
- *
- * @see https://www.drupal.org/node/3027453
- */
-function menu_ui_get_menus($all = TRUE) {
-  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\system\Entity\Menu::loadMultiple() instead. See https://www.drupal.org/node/3027453', E_USER_DEPRECATED);
-  if ($custom_menus = Menu::loadMultiple()) {
-    if (!$all) {
-      $custom_menus = array_diff_key($custom_menus, menu_list_system_menus());
-    }
-    foreach ($custom_menus as $menu_name => $menu) {
-      $custom_menus[$menu_name] = $menu->label();
-    }
-    asort($custom_menus);
-  }
-  return $custom_menus;
-}
-
 /**
  * Implements hook_preprocess_HOOK() for block templates.
  */
diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuLegacyTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuLegacyTest.php
deleted file mode 100644
index 33f203e4a5b6..000000000000
--- a/core/tests/Drupal/KernelTests/Core/Menu/MenuLegacyTest.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-namespace Drupal\KernelTests\Core\Menu;
-
-use Drupal\KernelTests\KernelTestBase;
-
-/**
- * Deprecation test cases for the menu layer.
- *
- * @group legacy
- */
-class MenuLegacyTest extends KernelTestBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  protected static $modules = ['menu_ui', 'system', 'user'];
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function setUp(): void {
-    parent::setUp();
-    $this->installConfig('system');
-  }
-
-  /**
-   * Tests deprecation of the menu_list_system_menus() function.
-   */
-  public function testListSystemMenus(): void {
-    $this->expectDeprecation('menu_list_system_menus() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\system\Entity\Menu::loadMultiple() instead. See https://www.drupal.org/node/3027453');
-    $this->assertSame([
-      'tools' => 'Tools',
-      'admin' => 'Administration',
-      'account' => 'User account menu',
-      'main' => 'Main navigation',
-      'footer' => 'Footer menu',
-    ], menu_list_system_menus());
-  }
-
-  /**
-   * Tests deprecation of the menu_ui_get_menus() function.
-   */
-  public function testMenuUiGetMenus(): void {
-    $this->expectDeprecation('menu_ui_get_menus() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\system\Entity\Menu::loadMultiple() instead. See https://www.drupal.org/node/3027453');
-    $this->assertSame([
-      'admin' => 'Administration',
-      'footer' => 'Footer',
-      'main' => 'Main navigation',
-      'tools' => 'Tools',
-      'account' => 'User account menu',
-    ], menu_ui_get_menus());
-  }
-
-}
-- 
GitLab