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
| 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 |
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | update_php_doesn_t_work-1433996-37.patch | 600 bytes | yogeshmpawar |
| #24 | update-1433996-23.patch | 599 bytes | fatfish |
| #15 | update-1433996-15.patch | 569 bytes | pushpinderchauhan |
| #12 | update-1433996-12.patch | 908 bytes | Anonymous (not verified) |
| #3 | update-1433996-3.patch | 536 bytes | David_Rothstein |
Comments
Comment #1
catchLooks like #951644: Requirement warnings (e.g. for PHP memory limit) are not shown on install or update unless there is a requirement error also broke this.
Comment #2
catchComment #3
David_Rothstein commentedI 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.
Comment #4
chx commentedUm. Why? bootstrap.inc already handles this in drupal_environment_initialize. Why do we need more / new / untested code?
Comment #5
David_Rothstein commentedBy 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.Comment #6
David_Rothstein commented#3: update-1433996-3.patch queued for re-testing.
Comment #7
welly commentedI've written an issue summary.
Comment #7.0
welly commentedUpdated issue summary
Comment #7.1
welly commentedAmend to Problem/Motivation
Comment #8
kerasai commented#3: update-1433996-3.patch queued for re-testing.
Comment #9
pneedle commentedI 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.
Comment #10
pplantinga commentedThe broken links are being addressed by #2017769: Links from update_helpful_links() should point to site root and not to update.php
Comment #10.0
pplantinga commentedAdded user name to original report section
Comment #11
valthebaldComment #12
Anonymous (not verified) commentedSimple reroll.
Comment #15
pushpinderchauhan commentedRerolled.
Comment #16
jhedstromWhen trying to reproduce this issue to test, following this step:
simply breaks the site if I have the site in a subdirectory.
Comment #17
Anonymous (not verified) commentedComment #19
David_Rothstein commentedWhy did you mark this "needs work"?
Comment #20
Anonymous (not verified) commentedI 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.
Comment #21
jhedstromPatch no longer applies.
Comment #22
fatfish commentedIm going to work on this issue during the sprint
Comment #23
danylevskyiI'm a mentor. Helping @fatfish to work on the issue.
Comment #24
fatfish commentedauto merge
Comment #25
valthebaldAdded beta evaluation, should be safe to RTBC if testbot says it's OK
Comment #26
danylevskyiComment #27
danylevskyiUnfortunately, the patch doesn't fix the problem. "Continue" button on update.php page still points to /drupal/update.php instead of /update.php.
Comment #28
danylevskyiComment #29
opdaviesThe patch in #24 applies cleanly to HEAD.
Comment #33
jerenus commented#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
Comment #34
jerenus commentedComment #35
cilefen commentedI switched the wrong triage tag for the correct one.
Comment #36
cilefen commented@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:
Thank you!
Comment #37
yogeshmpawarRe-roll of the #24 patch because it's failed to apply on 8.4.x branch.
Comment #39
jofitzRemoved Needs Reroll tag.
Comment #40
alexpottDiscussed 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.
Comment #41
alexpottGiven the code that generates the url for the continue button is:
It seems #2548095: Add option to Url() to force the site base_url to be used is very relevant.
Comment #51
larowlanComment #52
lendudeCan’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:
And we don't do
base_urlanymore 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?
Comment #55
quietone commentedlendude 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.