From bc719d0c550fe0f6120676481d3ed5e039db4790 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Sat, 29 Nov 2008 09:33:51 +0000
Subject: [PATCH] - Patch #337820 by Dave Reid, Damien Tournoud, et al: rename
 menu path 'logout' to 'user/logout'.  For real now.

---
 modules/locale/locale.test                  |  6 +++---
 modules/menu/menu.test                      |  7 +++----
 modules/poll/poll.test                      |  2 +-
 modules/simpletest/drupal_web_test_case.php |  2 +-
 modules/system/system.install               | 10 ++++++++++
 modules/user/user.module                    | 14 +++++++-------
 robots.txt                                  |  4 ++--
 7 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index 45a014755e53..26904e8247d5 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -55,7 +55,7 @@ class LocaleTestCase extends DrupalWebTestCase {
     // No t() here, we do not want to add this string to the database and it's
     // surely not translated yet.
     $this->assertText($native, 'Test language added');
-    $this->drupalGet('logout');
+    $this->drupalLogout();
 
     // Search for the name and translate it.
     $this->drupalLogin($translate_user);
@@ -87,7 +87,7 @@ class LocaleTestCase extends DrupalWebTestCase {
     $this->drupalPost('admin/build/translate/search', $search, t('Search'));
     // The indicator should not be here.
     $this->assertNoRaw($language_indicator, 'String is translated');
-    $this->drupalGet('logout');
+    $this->drupalLogout();
 
     // Delete the language.
     $this->drupalLogin($admin_user);
@@ -101,7 +101,7 @@ class LocaleTestCase extends DrupalWebTestCase {
     $this->assertNoText($langcode, 'Language code not found');
     $this->assertNoText($name, 'Name not found');
     $this->assertNoText($native, 'Native not found');
-    $this->drupalGet('logout');
+    $this->drupalLogout();
 
     // Delete the name string.
     $this->drupalLogin($translate_user);
diff --git a/modules/menu/menu.test b/modules/menu/menu.test
index bd453a097c1a..45dd980dc662 100644
--- a/modules/menu/menu.test
+++ b/modules/menu/menu.test
@@ -365,10 +365,9 @@ class MenuTestCase extends DrupalWebTestCase {
    * Get standard menu item.
    *
    */
-  private function getStandardMenuItem()
-  {
-    // Retrieve menu link id (presumably the Log out menu item, but not necessary).
-    $mlid = db_result(db_query("SELECT MIN(mlid) FROM {menu_links} WHERE module = 'system' AND hidden = 0 AND has_children = 0"));
+  private function getStandardMenuItem() {
+    // Retrieve menu link id of the Log out menu item, which will always be on the front page.
+    $mlid = db_query("SELECT mlid FROM {menu_links} WHERE module = 'system' AND router_path = 'user/logout'")->fetchField();
     $this->assertTrue($mlid > 0, 'Standard menu link id was found');
     // Load menu item.
     // Use api function so that link is translated for rendering.
diff --git a/modules/poll/poll.test b/modules/poll/poll.test
index 0806d4720b36..e91f689c7ca5 100644
--- a/modules/poll/poll.test
+++ b/modules/poll/poll.test
@@ -106,7 +106,7 @@ class PollVoteTestCase extends PollTestCase {
     $title = $this->randomName();
     $choices = $this->_generateChoices(7);
     $poll_nid = $this->pollCreate($title, $choices, FALSE);
-    $this->drupalGet('logout');
+    $this->drupalLogout();
 
     $web_user = $this->drupalCreateUser(array('cancel own vote', 'inspect all votes', 'vote on polls', 'access content'));
     $this->drupalLogin($web_user);
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 4704e88b7800..73aec6f2ead3 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -745,7 +745,7 @@ protected function drupalLogin($user = NULL) {
    */
   protected function drupalLogout() {
     // Make a request to the logout page.
-    $this->drupalGet('logout');
+    $this->drupalGet('user/logout');
 
     // Load the user page, the idea being if you were properly logged out you should be seeing a login screen.
     $this->drupalGet('user');
diff --git a/modules/system/system.install b/modules/system/system.install
index ae9cd81cddfd..ba0d5b59acc1 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -3132,6 +3132,16 @@ function system_update_7014() {
   return $ret;
 }
 
+/**
+ * Change the user logout path.
+ */
+function system_update_7015() {
+  $ret = array();
+  $ret[] = update_sql("UPDATE {menu_links} SET link_path = 'user/logout' WHERE link_path = 'logout'");
+  $ret[] = update_sql("UPDATE {menu_links} SET router_path = 'user/logout' WHERE router_path = 'logout'");
+  return $ret;
+}
+
 /**
  * @} End of "defgroup updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
diff --git a/modules/user/user.module b/modules/user/user.module
index cdb912d927b4..0ee98a979c10 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -977,6 +977,13 @@ function user_menu() {
     'type' => MENU_CALLBACK,
   );
 
+  $items['user/logout'] = array(
+    'title' => 'Log out',
+    'access callback' => 'user_is_logged_in',
+    'page callback' => 'user_logout',
+    'weight' => 10,
+  );
+
   // User administration pages.
   $items['admin/user'] = array(
     'title' => 'User management',
@@ -1033,13 +1040,6 @@ function user_menu() {
     'type' => MENU_CALLBACK,
   );
 
-  $items['logout'] = array(
-    'title' => 'Log out',
-    'access callback' => 'user_is_logged_in',
-    'page callback' => 'user_logout',
-    'weight' => 10,
-  );
-
   $items['user/%user_uid_optional'] = array(
     'title' => 'My account',
     'title callback' => 'user_page_title',
diff --git a/robots.txt b/robots.txt
index 3c9487050280..de875fedf898 100644
--- a/robots.txt
+++ b/robots.txt
@@ -43,19 +43,19 @@ Disallow: /xmlrpc.php
 Disallow: /admin/
 Disallow: /comment/reply/
 Disallow: /contact/
-Disallow: /logout/
 Disallow: /node/add/
 Disallow: /search/
 Disallow: /user/register/
 Disallow: /user/password/
 Disallow: /user/login/
+Disallow: /user/logout/
 # Paths (no clean URLs)
 Disallow: /?q=admin/
 Disallow: /?q=comment/reply/
 Disallow: /?q=contact/
-Disallow: /?q=logout/
 Disallow: /?q=node/add/
 Disallow: /?q=search/
 Disallow: /?q=user/password/
 Disallow: /?q=user/register/
 Disallow: /?q=user/login/
+Disallow: /?q=user/logout/
-- 
GitLab