Index: modules/shortcut/shortcut.module =================================================================== RCS file: /cvs/drupal/drupal/modules/shortcut/shortcut.module,v retrieving revision 1.24 diff -u -r1.24 shortcut.module --- modules/shortcut/shortcut.module 6 Mar 2010 06:33:14 -0000 1.24 +++ modules/shortcut/shortcut.module 23 Jun 2010 22:49:07 -0000 @@ -625,7 +625,11 @@ * Implements hook_preprocess_page(). */ function shortcut_preprocess_page(&$variables) { - if (shortcut_set_edit_access()) { + // Only display the shortcut link if the user has the ability to edit + // shortcuts and if the page's actual content is being shown (for example, + // we do not want to display it on "access denied" or "page not found" + // pages). + if (shortcut_set_edit_access() && ($item = menu_get_item()) && $item['access']) { $link = $_GET['q']; $query_parameters = drupal_get_query_parameters(); if (!empty($query_parameters)) { Index: modules/shortcut/shortcut.test =================================================================== RCS file: /cvs/drupal/drupal/modules/shortcut/shortcut.test,v retrieving revision 1.2 diff -u -r1.2 shortcut.test --- modules/shortcut/shortcut.test 17 Jun 2010 13:16:57 -0000 1.2 +++ modules/shortcut/shortcut.test 23 Jun 2010 22:49:07 -0000 @@ -187,6 +187,31 @@ $mlids = $this->getShortcutInformation($saved_set, 'mlid'); $this->assertFalse(in_array($set->links[0]['mlid'], $mlids), 'Successfully deleted a shortcut.'); } + + /** + * Tests that the add shortcut link is not displayed for 404/403 errors. + * + * Tests that the "Add to shortcuts" link is not displayed on a page not + * found or a page the user does not have access to. + */ + function testNoShortcutLink() { + // Set the theme to seven. The default theme (Garland) does not display + // shortcut links. + variable_set('theme_default', 'seven'); + + $this->drupalGet('page-that-does-not-exist'); + $this->assertNoRaw('add-shortcut', t('Add to shortcuts link was not shown on a page not found.')); + + // The user does not have access to this path. + $this->drupalGet('admin/modules'); + $this->assertNoRaw('add-shortcut', t('Add to shortcuts link was not shown on a page the user does not have access to.')); + + // Verify that the testing mechanism works by verifying the shortcut + // link appears on admin/content/node. + $this->drupalGet('admin/content/node'); + $this->assertRaw('add-shortcut', t('Add to shortcuts link was shown on a page the user does have access to.')); + + } } /**