Problem/Motivation

An installation of Drupal has been placed in a subdirectory (/drupal) of webroot. The .htaccess file contains the RewriteBase directive to point to the subdirectory.

RewriteBase /drupal

The base_url variable in the settings.php file has been set to the base url of the site excluding the subdirectory (http://example.com).

On running update.php on the base URL (http://example.com) when updating Drupal version 7.8 to 7.12, the URL continue button link is pointing to the base URL plus the subdirectory (http://example.com/drupal/update.php) as opposed to just the base URL (http://example.com/update.php).

The issue appears to be limited to sites using the RewriteBase directive and using the update.php file from a previous release of Drupal (7.8) is working correctly.

Here as an additional info for installing Drupal withing subdirectory:
http://www.trevorsimonton.com/blog/drupal-sudirectory-install-htaccess-s...

Proposed resolution

An untested patch has been provided to fix the issue, that gets the URL path using parse_url rather than using the SCRIPT_NAME server variable

Remaining tasks

The patch needs testing.

User interface changes

None

API changes

None

Original report by [goood]

I have problem with new version of update.php script
I updated from D7.8 to D7.12. Drupal is located in folder /drupal of webroot and web has url in format http://www.example.com (not http://www.example.com/drupal)

In .htaccess I have
RewriteBase /drupal

In settings.php I have
$base_url = 'http://www.example.com';

Web works fine, but update.php generates wrong url for continue button. There is http://www.example.com/drupal/update.php instead of http://www.example.com/update.php !

Finally I used update.php from previous version (D7.8) and it works fine, because there is another way of generating url

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug since the behavior of update.php is not as expected
Issue priority Major because Drupal install in subfolder is quite a common case.
Unfrozen changes Unfrozen because it's a bug fix

Comments

catch’s picture

Title: update.php not work when drupal installed in subfolder » update.php doesn't work when drupal installed in subfolder
Version: 7.12 » 8.x-dev
Issue tags: +Needs backport to D7
catch’s picture

Component: update.module » database update system
David_Rothstein’s picture

Title: update.php doesn't work when drupal installed in subfolder » update.php doesn't work when Drupal is installed in a subfolder and RewriteBase is used
Status: Active » Needs review
StatusFileSize
new536 bytes

I wrote that patch and run Drupal in a subfolder all the time, so I know it works in the general case :) ... I think this issue is limited to sites using RewriteBase?

Here is a mostly untested patch that might help.

chx’s picture

Um. Why? bootstrap.inc already handles this in drupal_environment_initialize. Why do we need more / new / untested code?

David_Rothstein’s picture

By using request_uri() the patch is already making it reuse work that was done in bootstrap.inc - and therefore fixing the bug :) But as far as I recall, most of the rest of what happens in bootstrap.inc doesn't apply directly to install.php or update.php. See also #1547184: Refactor Core scripts .

If there's some use for the equivalent of parse_url(request_uri(), PHP_URL_PATH) on normal Drupal page requests, I suppose we could add it to bootstrap.inc also? But I don't think it should happen in this issue unless it turns out to be really easy.

David_Rothstein’s picture

#3: update-1433996-3.patch queued for re-testing.

welly’s picture

I've written an issue summary.

welly’s picture

Issue summary: View changes

Updated issue summary

welly’s picture

Issue summary: View changes

Amend to Problem/Motivation

kerasai’s picture

#3: update-1433996-3.patch queued for re-testing.

pneedle’s picture

I can confirm that update.php does not work with this patch
and with this configuration:
Mac OS X 10.7.5
PHP ver 5.3.15
Apache 2.2.22
MySQL Server version: 5.5.19-log

After running update.php, the message box is displayed saying "No pending updates."
However, the "Front page" hyperlink directs back to: /core/update.php
and the "Administration pages" hyperlink directs back to: /core/admin/update.php
The user doesn't have a valid link out.

pplantinga’s picture

pplantinga’s picture

Issue summary: View changes

Added user name to original report section

valthebald’s picture

Issue tags: +Needs reroll
Anonymous’s picture

Issue tags: -Needs reroll
StatusFileSize
new908 bytes

Simple reroll.

Status: Needs review » Needs work

The last submitted patch, 12: update-1433996-12.patch, failed testing.

pushpinderchauhan’s picture

Status: Needs work » Needs review
StatusFileSize
new569 bytes

Rerolled.

jhedstrom’s picture

When trying to reproduce this issue to test, following this step:

The base_url variable in the settings.php file has been set to the base url of the site excluding the subdirectory (http://example.com).

simply breaks the site if I have the site in a subdirectory.

Anonymous’s picture

Status: Needs review » Needs work

Status: Needs work » Needs review
David_Rothstein’s picture

Why did you mark this "needs work"?

Anonymous’s picture

I started reviewing this, but realized too late I'm running nginx on this box and thus the .htaccess file is ignored. After removing my comment, I shouldn't have clicked the save button. My apologies.

jhedstrom’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch no longer applies.

fatfish’s picture

Im going to work on this issue during the sprint

danylevskyi’s picture

I'm a mentor. Helping @fatfish to work on the issue.

fatfish’s picture

Status: Needs work » Needs review
StatusFileSize
new599 bytes

auto merge

valthebald’s picture

Issue summary: View changes

Added beta evaluation, should be safe to RTBC if testbot says it's OK

danylevskyi’s picture

Issue summary: View changes
danylevskyi’s picture

Unfortunately, the patch doesn't fix the problem. "Continue" button on update.php page still points to /drupal/update.php instead of /update.php.

danylevskyi’s picture

Status: Needs review » Needs work
opdavies’s picture

Issue tags: -Needs reroll

The patch in #24 applies cleanly to HEAD.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jerenus’s picture

Version: 8.3.x-dev » 8.4.x-dev
Issue tags: +Triaged core major, +Baltimore2017

#27 +1. It seems the problem is still here.

Reproduce:
Drupal 8.4.x + installed with subfolder (/test) + Patch #24

The /test/update.php page is still working but once I click the Continue button:

Continue ->
It will still go to the path like: /test/update.php/selection

jerenus’s picture

Issue tags: +Needs reroll
cilefen’s picture

Issue tags: -Triaged core major +Triaged for D8 major current state

I switched the wrong triage tag for the correct one.

cilefen’s picture

@Jerenus That's good work so far on triage. I am giving you credit on this issue based on the amount of work done. Be aware we like to see the triage steps documented (even if brief). It is the only way to know if the triage has actually been completed. Here are some made-up examples of documented triage steps:

  • I tested the steps to reproduce and they did (or did not) work (so I am tagging it "Needs issue summary update").
  • I searched for duplicate issues but could not find any.
  • I checked the issue summary and it is accurate and up-to-date.
  • Etc...

Thank you!

yogeshmpawar’s picture

Status: Needs work » Needs review
StatusFileSize
new600 bytes

Re-roll of the #24 patch because it's failed to apply on 8.4.x branch.

Status: Needs review » Needs work

The last submitted patch, 37: update_php_doesn_t_work-1433996-37.patch, failed testing.

jofitz’s picture

Issue tags: -Needs reroll

Removed Needs Reroll tag.

alexpott’s picture

Issue tags: +Triaged core major

Discussed with @catch, @cilefen, @effulgentsia, @lauriii, and @xjm. We agree this is a major bug. The only reason this is not critical is because the set up is unusual. We agreed that discovering that update.php doesn't work why trying to apply a security upgrade would be a really bad time to find out.

alexpott’s picture

Given the code that generates the url for the continue button is:

    $build['link'] = [
      '#type' => 'link',
      '#title' => $this->t('Continue'),
      '#attributes' => ['class' => ['button', 'button--primary']],
      // @todo Revisit once https://www.drupal.org/node/2548095 is in.
      '#url' => Url::fromUri('base://selection'),
    ];

It seems #2548095: Add option to Url() to force the site base_url to be used is very relevant.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

lendude’s picture

Status: Needs work » Postponed (maintainer needs more info)

Can’t reproduce with just uncommenting RewriteBase /drupalin .htaccess when using site in the subdir /drupal running on Apache.

So it feels like this was a vital step in breaking this:

The base_url variable in the settings.php file has been set to the base url of the site excluding the subdirectory

And we don't do base_url anymore in D9.

Should we move this back to D7 and see if it is still reproducible there or does anybody still have any steps to reproduce this on D9?

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 10.1.x-dev » 7.x-dev
Issue tags: -

lendude was not able to reproduce this problem on Drupal 9, see #52. In the intervening 6 months no one has confirmed that this problem still exists in any supported version of Drupal. However, in case this is applicable to Drupal 7 I am changing the version.

Status: Postponed (maintainer needs more info) » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.