From d2c38c4539a55aaff253b4253e285f28fddf7252 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 4 May 2015 16:17:40 -0700
Subject: [PATCH] Issue #2478151 by willzyx: Shortcuts to pages generated by
 views are not recognized as added to the shortcutset and are being added
 multiple times

---
 core/modules/shortcut/shortcut.module          |  2 +-
 .../shortcut/src/Tests/ShortcutLinksTest.php   | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index af62baccc597..b406bc5c3c30 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -321,7 +321,7 @@ function shortcut_preprocess_page(&$variables) {
     $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(array('shortcut_set' => $shortcut_set->id()));
     /** @var \Drupal\shortcut\ShortcutInterface $shortcut */
     foreach ($shortcuts as $shortcut) {
-      if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName() && $shortcut_url->getRouteParameters() == $route_match->getParameters()->all()) {
+      if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName()) {
         $shortcut_id = $shortcut->id();
         break;
       }
diff --git a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
index 7adc1ada7a3e..032cf6fae3f1 100644
--- a/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/src/Tests/ShortcutLinksTest.php
@@ -135,6 +135,24 @@ public function testShortcutQuickLink() {
 
     $this->drupalGet('admin/structure');
     $this->assertNoLink('Cron', 'Shortcut link removed from different page');
+
+    $this->drupalGet('admin/people');
+
+    // Test the "Add to shortcuts" link for a page generated by views.
+    $this->clickLink('Add to Default shortcuts');
+    $this->assertText('Added a shortcut for People.');
+    // Due to the structure of the markup in the link ::assertLink() doesn't
+    // works here.
+    $link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Remove from Default shortcuts'));
+    $this->assertTrue(!empty($link), 'Link Remove from Default shortcuts found.');
+
+    // Test the "Remove from  shortcuts" link for a page generated by views.
+    $this->clickLink('Remove from Default shortcuts');
+    $this->assertText('The shortcut People has been deleted.');
+    // Due to the structure of the markup in the link ::assertLink() doesn't
+    // works here.
+    $link = $this->xpath('//a[normalize-space()=:label]', array(':label' => 'Add to Default shortcuts'));
+    $this->assertTrue(!empty($link), 'Link Add to Default shortcuts found.');
   }
 
   /**
-- 
GitLab