From 9315a45e0155541a22d990cfbf74701b0e9980a2 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Sat, 4 Oct 2014 17:29:36 +0200
Subject: [PATCH] Issue #2338759 by StryKaizer, tom_ek | alexpott: Fixed
 core/update.php is now just update.php.

---
 .htaccess                                                 | 2 +-
 core/UPGRADE.txt                                          | 2 +-
 core/lib/Drupal/Core/DrupalKernel.php                     | 8 ++++----
 .../Installer/Exception/AlreadyInstalledException.php     | 3 ++-
 core/modules/system/system.install                        | 4 ++--
 core/modules/system/system.module                         | 6 +++---
 core/modules/update/update.authorize.inc                  | 2 +-
 core/modules/update/update.module                         | 2 +-
 core/scripts/drupal.sh                                    | 2 +-
 9 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/.htaccess b/.htaccess
index c32b18211985..0ad7be304817 100644
--- a/.htaccess
+++ b/.htaccess
@@ -129,7 +129,7 @@ DirectoryIndex index.php index.html index.htm
   # Note: The following URI conditions are not anchored at the start (^),
   # because Drupal may be located in a subdirectory. To further improve
   # security, you can replace '!/' with '!^/'.
-  # Allow access to PHP files in /core (like update.php or install.php):
+  # Allow access to PHP files in /core (like authorize.php or install.php):
   RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
   # Allow access to test-specific PHP files:
   RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php$
diff --git a/core/UPGRADE.txt b/core/UPGRADE.txt
index 420f6ad2a364..7c700505e2c1 100644
--- a/core/UPGRADE.txt
+++ b/core/UPGRADE.txt
@@ -95,7 +95,7 @@ following the instructions in the INTRODUCTION section at the top of this file:
 
 5. Re-apply any modifications to files such as .htaccess or robots.txt.
 
-6. Run update.php by visiting http://www.example.com/core/update.php (replace
+6. Run update.php by visiting http://www.example.com/update.php (replace
    www.example.com with your domain name). This will update the core database
    tables.
 
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index b4c2567b72b2..6a9b78d8b88f 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -818,8 +818,8 @@ protected function initializeRequestGlobals(Request $request) {
       // For a request URI of '/index.php/foo', $_SERVER['SCRIPT_NAME'] is
       // '/index.php', whereas $_SERVER['PHP_SELF'] is '/index.php/foo'.
       if ($dir = rtrim(dirname($request->server->get('SCRIPT_NAME')), '\/')) {
-        // Remove "core" directory if present, allowing install.php, update.php,
-        // and others to auto-detect a base path.
+        // Remove "core" directory if present, allowing install.php,
+        // authorize.php, and others to auto-detect a base path.
         $core_position = strrpos($dir, '/core');
         if ($core_position !== FALSE && strlen($dir) - 5 == $core_position) {
           $base_path = substr($dir, 0, $core_position);
@@ -855,7 +855,7 @@ protected function initializeRequestGlobals(Request $request) {
         if (strpos(request_uri(TRUE) . '/', $base_path . $script_path) !== 0) {
           $script_path = '';
         }
-        // @todo Temporary BC for install.php, update.php, and other scripts.
+        // @todo Temporary BC for install.php, authorize.php, and other scripts.
         //   - http://drupal.org/node/1547184
         //   - http://drupal.org/node/1546082
         if ($script_path !== 'index.php/') {
@@ -891,7 +891,7 @@ protected function initializeCookieGlobals(Request $request) {
       // to use the same session identifiers across HTTP and HTTPS.
       $session_name = $request->getHost() . $request->getBasePath();
       // Replace "core" out of session_name so core scripts redirect properly,
-      // specifically install.php and update.php.
+      // specifically install.php.
       $session_name = preg_replace('/\/core$/', '', $session_name);
       // HTTP_HOST can be modified by a visitor, but has been sanitized already
       // in DrupalKernel::bootEnvironment().
diff --git a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
index 3bdb0a3fc9f4..19436b0cfc61 100644
--- a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
+++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php
@@ -26,10 +26,11 @@ public function __construct(TranslationInterface $string_translation) {
     $title = $this->t('Drupal already installed');
     $message = $this->t('<ul>
 <li>To start over, you must empty your existing database and copy <em>default.settings.php</em> over <em>settings.php</em>.</li>
-<li>To upgrade an existing installation, proceed to the <a href="!base-url/core/update.php">update script</a>.</li>
+<li>To upgrade an existing installation, proceed to the <a href="!update-url">update script</a>.</li>
 <li>View your <a href="!base-url">existing site</a>.</li>
 </ul>', array(
       '!base-url' => $GLOBALS['base_url'],
+      '!update-url' => $GLOBALS['base_path'] . 'update.php',
     ));
     parent::__construct($message, $title);
   }
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 788b9e10a74b..868b2eba1195 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -448,7 +448,7 @@ function system_requirements($phase) {
         if (max($updates) > $default) {
           $requirements['update']['severity'] = REQUIREMENT_ERROR;
           $requirements['update']['value'] = t('Out of date');
-          $requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href="@update">database update script</a> immediately.', array('@update' => base_path() . 'core/update.php'));
+          $requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href="@update">database update script</a> immediately.', array('@update' => \Drupal::url('system.db_update')));
           break;
         }
       }
@@ -456,7 +456,7 @@ function system_requirements($phase) {
     if (!isset($requirements['update']['severity']) && \Drupal::service('entity.definition_update_manager')->needsUpdates()) {
       $requirements['update']['severity'] = REQUIREMENT_ERROR;
       $requirements['update']['value'] = t('Out of date');
-      $requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href="@update">database update script</a> immediately.', array('@update' => base_path() . 'update.php'));
+      $requirements['update']['description'] = t('Some modules have database schema updates to install. You should run the <a href="@update">database update script</a> immediately.', array('@update' => \Drupal::url('system.db_update')));
     }
   }
 
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index a44b1fe02b89..d02573b04274 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -113,14 +113,14 @@ function system_help($route_name, RouteMatchInterface $route_match) {
       $output = '<p>' . t('Download additional <a href="@modules">contributed modules</a> to extend Drupal\'s functionality.', array('@modules' => 'http://drupal.org/project/modules')) . '</p>';
       if (\Drupal::moduleHandler()->moduleExists('update')) {
         if (update_manager_access()) {
-          $output .= '<p>' . t('Regularly review and install <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => $base_url . '/core/update.php', '@updates' => \Drupal::url('update.status'))) . '</p>';
+          $output .= '<p>' . t('Regularly review and install <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => \Drupal::url('system.db_update'), '@updates' => \Drupal::url('update.status'))) . '</p>';
         }
         else {
-          $output .= '<p>' . t('Regularly review <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => $base_url . '/core/update.php', '@updates' => \Drupal::url('update.status'))) . '</p>';
+          $output .= '<p>' . t('Regularly review <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => \Drupal::url('system.db_update'), '@updates' => \Drupal::url('update.status'))) . '</p>';
         }
       }
       else {
-        $output .= '<p>' . t('Regularly review available updates to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated. Enable the Update Manager module to update and install modules and themes.', array('@update-php' => $base_url . '/core/update.php')) . '</p>';
+        $output .= '<p>' . t('Regularly review available updates to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated. Enable the Update Manager module to update and install modules and themes.', array('@update-php' => \Drupal::url('system.db_update'))) . '</p>';
       }
       return $output;
 
diff --git a/core/modules/update/update.authorize.inc b/core/modules/update/update.authorize.inc
index 3bfdbcf4bcd6..8709e56e6324 100644
--- a/core/modules/update/update.authorize.inc
+++ b/core/modules/update/update.authorize.inc
@@ -227,7 +227,7 @@ function update_authorize_update_batch_finished($success, $results) {
   // Since we're doing an update of existing code, always add a task for
   // running update.php.
   $results['tasks'][] = t('Your modules have been downloaded and updated.');
-  $results['tasks'][] = t('<a href="@update">Run database updates</a>', array('@update' => base_path() . 'core/update.php'));
+  $results['tasks'][] = t('<a href="@update">Run database updates</a>', array('@update' => \Drupal::url('system.db_update')));
 
   // Unset the variable since it is no longer needed.
   unset($_SESSION['maintenance_mode']);
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index 061937606f31..44aa884a3e22 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -615,7 +615,7 @@ function update_verify_update_archive($project, $archive_file, $directory) {
   // Make sure this isn't a tarball of Drupal core.
   if (
     file_exists("$directory/$project/index.php")
-    && file_exists("$directory/$project/core/update.php")
+    && file_exists("$directory/$project/core/install.php")
     && file_exists("$directory/$project/core/includes/bootstrap.inc")
     && file_exists("$directory/$project/core/modules/node/node.module")
     && file_exists("$directory/$project/core/modules/system/system.module")
diff --git a/core/scripts/drupal.sh b/core/scripts/drupal.sh
index 951434150cb0..de8e864b62f1 100755
--- a/core/scripts/drupal.sh
+++ b/core/scripts/drupal.sh
@@ -44,7 +44,7 @@
               i.e. if URI is set to http://default/bar/foo.php
               and bar/foo.php exists, this script will be executed without
               bootstrapping Drupal. To execute Drupal's update.php, specify
-              http://default/core/update.php as the URI.
+              http://default/update.php as the URI.
 
 
 To run this script without --root argument invoke it from the root directory
-- 
GitLab