From 235a162831623cfc687bebba46cc6bb5ad21ee99 Mon Sep 17 00:00:00 2001
From: tedbow <tedbow@240860.no-reply.drupal.org>
Date: Thu, 23 Sep 2021 20:03:04 +0000
Subject: [PATCH] Issue #3238852 by tedbow, phenaproxima: Alter the existing
 "update" tabs use our routes

---
 automatic_updates.links.task.yml         | 10 ----------
 automatic_updates.module                 | 19 +++++++++++++++++++
 automatic_updates.routing.yml            |  9 +++++++++
 tests/src/Build/CoreUpdateTest.php       |  2 +-
 tests/src/Functional/UpdaterFormTest.php |  2 --
 5 files changed, 29 insertions(+), 13 deletions(-)
 delete mode 100644 automatic_updates.links.task.yml

diff --git a/automatic_updates.links.task.yml b/automatic_updates.links.task.yml
deleted file mode 100644
index 239f899432..0000000000
--- a/automatic_updates.links.task.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-automatic_updates.report_update:
-  route_name: automatic_updates.report_update
-  base_route: system.admin_reports
-  title: Automatic Updates
-  weight: 15
-automatic_updates.module_update:
-  route_name: automatic_updates.module_update
-  base_route: system.modules_list
-  title: Automatic Updates
-  weight: 15
diff --git a/automatic_updates.module b/automatic_updates.module
index 1379ccbb91..48b88b1898 100644
--- a/automatic_updates.module
+++ b/automatic_updates.module
@@ -84,3 +84,22 @@ function automatic_updates_form_update_manager_update_form_alter(&$form, FormSta
     }
   }
 }
+
+/**
+ * Implements hook_local_tasks_alter().
+ */
+function automatic_updates_local_tasks_alter(array &$local_tasks) {
+  // The Update module's update form only allows updating modules and themes
+  // via archive files, which could produce unexpected results on a site using
+  // our Composer-based updater.
+  $new_routes = [
+    'update.report_update' => 'automatic_updates.report_update',
+    'update.module_update' => 'automatic_updates.module_update',
+    'update.theme_update' => 'automatic_updates.theme_update',
+  ];
+  foreach ($new_routes as $local_task_id => $new_route) {
+    if (!empty($local_tasks[$local_task_id])) {
+      $local_tasks[$local_task_id]['route_name'] = $new_route;
+    }
+  }
+}
diff --git a/automatic_updates.routing.yml b/automatic_updates.routing.yml
index 4c12d0f5f7..a886f78046 100644
--- a/automatic_updates.routing.yml
+++ b/automatic_updates.routing.yml
@@ -33,3 +33,12 @@ automatic_updates.module_update:
     _permission: 'administer software updates'
   options:
     _admin_route: TRUE
+automatic_updates.theme_update:
+  path: '/admin/theme/automatic-update'
+  defaults:
+    _form: '\Drupal\automatic_updates\Form\UpdaterForm'
+    _title: 'Update'
+  requirements:
+    _permission: 'administer software updates'
+  options:
+    _admin_route: TRUE
diff --git a/tests/src/Build/CoreUpdateTest.php b/tests/src/Build/CoreUpdateTest.php
index d391cda0be..cf0d7256ea 100644
--- a/tests/src/Build/CoreUpdateTest.php
+++ b/tests/src/Build/CoreUpdateTest.php
@@ -120,7 +120,7 @@ class CoreUpdateTest extends UpdateTestBase {
     $assert_session = $mink->assertSession();
     $this->visit('/admin/modules');
     $assert_session->pageTextContains('There is a security update available for your version of Drupal.');
-    $page->clickLink('Automatic Updates');
+    $page->clickLink('Update');
     $assert_session->pageTextNotContains('There is a security update available for your version of Drupal.');
     $page->pressButton('Update');
     $this->waitForBatchJob();
diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php
index df68ffc7b1..d03229896d 100644
--- a/tests/src/Functional/UpdaterFormTest.php
+++ b/tests/src/Functional/UpdaterFormTest.php
@@ -99,8 +99,6 @@ class UpdaterFormTest extends BrowserTestBase {
     $this->clickLink('Extend');
     $assert_session->pageTextContainsOnce('There is a security update available for your version of Drupal.');
     $this->clickLink('Update');
-    $assert_session->pageTextContainsOnce('Drupal core updates are supported by the enabled Automatic Updates module');
-    $this->clickLink('Automatic Updates module');
     $assert_session->pageTextNotContains('There is a security update available for your version of Drupal.');
     $cells = $assert_session->elementExists('css', '#edit-projects .update-update-security')
       ->findAll('css', 'td');
-- 
GitLab