Beta phase evaluation
| Issue category | Bug |
|---|---|
| Issue priority | Major |
| Prioritized changes | Yes. This fixes a regression. |
| Disruption | Not disruptive and does not require a BC layer. |
Problem/Motivation
If you install Drupal on Apache without rewrite enabled then you are left with a site that appears to work but can't receive form submissions. There are no warnings during install and no error messages, to the uninformed user form submissions (logging in, creating content, changing configuration etc. are just ignored.).
Clean urls appear to work, thanks to ErrorDocument in .htaccess forward 404 to index.php however this does not provide a mechanism to capture post data in the original request body.
Urls can be manually changed to include index.php/ however you would have to know this technique to move to non-clean urls, also Drupal 8 currently does not even work fully with non-clean urls (some links such as home link etc. lose the index.php/) (should be considered as a separate issue. Note also thate index.php/ urls will not work if Drupal is installed in a sub-directory.
Many people are falling foul of this problem even an experience user may forget to enable rewrite or not realise that some Linux distributions (Ubuntu 14.04 included, do not have it enabled by default).
The motivation for this issue is to provide a simple focused solution that ensures that if a user installs Drupal 8 using Apache without rewrite enabled it just works. The solution should not make anything else worse but neither should it be confused with any clean url, warning, messaging or installation issues.
If it is not possible to fix this then either Rewrite becomes a Requirement (unblocking warnings/errors to be generated on install) or support for dirty urls has to be re-introduced.
Thanks also to @speely for finding the same problem: #2099311: User login not working if mod_rewrite is not enabled
Suggested commit message
git commit -m 'Issue #2382513 by chris_hall_hu_cheng, mikeker, joachim, quietone, shivanshuag, YesCT, Jeroen, joris_lucius, katy5289, sivaji@knackforge.com:: Regression fix: allow Drupal 8 to work without Apache mod_rewrite.'
Proposed resolution
The simplest solution (and the only one I can visualise working at the moment) is to use the Apache FallbackResource directive (appears to be designed for just this purpose and does not rely on rewrite).
Note: Fallback resource raises the requirement for Apache to 2.2.16 see https://www.drupal.org/node/2382513#comment-9379857
Remaining tasks
- Done:
review feasibility of usingFallbackResourcedirective. - Done:
determine whether it was correct to remove ErrorDocument directive - Done (Apache 2.2.16 is only required if mod_rewrite is NOT enabled):
establish whether a requirement for Apache 2.2.16 (only applies to servers without rewrite enabled) is acceptable. - Done (https://www.drupal.org/node/2420781):
Add change record. - Add installer warning -- specifically for Apache < 2.2.16 and without mod_rewrite.
- Add test for installer warning
- Update https://www.drupal.org/requirements/webserver
User interface changes
None.
API changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #68 | 2382513-66-68.interdiff.txt | 2.33 KB | mikeker |
| #68 | 2382513-68.htaccess-mod_rewrite.patch | 5.2 KB | mikeker |
| #66 | 2382513-66.htaccess-mod_rewrite.patch | 4.78 KB | mikeker |
| #60 | 2382513-59-41.interdiff.txt | 3.64 KB | mikeker |
| #60 | 2382513-59-htaccess-mod_rewrite.patch | 4.81 KB | mikeker |
Comments
Comment #1
chris_hall_hu_cheng commentedAttaching a patch, worked for me, but needs independent review and testing.
Comment #2
mfbFallbackResource needs Apache 2.2.16 so we'd want to change the minimum apache version in core/INSTALL.txt from 2.0 (There is
<IfVersion>but I'm not sure this would be guaranteed to work either)Also I think it would be worth documenting that the /index.php directives only work if Drupal is being accessed via the top level of the URL, i.e. http://example.com/ but not http://example.com/drupal/
Comment #3
chris_hall_hu_cheng commented@mfb good point, I think IFVersion requires another module to be enabled though.
Since the bump in the php version number, is 2.2.16 really a problem?? I don't have a good view on the current landscape of shared hosting at the moment though.
I will update the issue and clean up the summary description in a bit.
this issue is really a 'shut up or put up' issue imho. every time something comes up about clean urls without rewrite not working etc. it always dissapates into discussions about other issues and "when this is fixed ... that will ..". I am hoping either this issue addresses the fundamental problem (somehow) or concludes that it is broken and cannot be fixed (and a bunch of other probably much more fundamental stuff needs doing).
it is a shame that the clean url switching etc. was ripped out of D8 so long ago without leaving something that worked in its place, I do understand that we needed to get away from all that ?q= but at the moment no rewrite = wtf, and we can't warn people on install because it is not a requirement (depending on what you read).
Comment #4
chris_hall_hu_cheng commentedComment #5
chris_hall_hu_cheng commentedComment #6
mfbin addition to the documentation suggestion - with this patch I don't think there is any reason to keep the ErrorDocument 404? (the index.php RewriteRule is still useful though for sites in subdirectories)
Comment #7
joelpittetThat is cool! Didn't know this directive existed, but seems like a simpler approach than mod_rewrite and removes a dependancy which is also cool, IMO;)
Symfony2 was also considering this in mid 2013:
@see https://groups.google.com/forum/#!topic/symfony2/B20W2wBSsiY
And mentioned in their docs:
http://silex.sensiolabs.org/doc/web_servers.html
Which references this article: https://www.adayinthelifeof.nl/2012/01/21/apaches-fallbackresource-your-...
Comment #8
13rac1 commentedI'm sorry. This new issue is a duplicate of #2099311: User login not working if mod_rewrite is not enabled since that issue describes the problem first. Please post this patch in the original issue.
Comment #9
chris_hall_hu_cheng commented@eosrei
I disagree, and have re-opened, #2099311 describes a subset of this issue imho, the purpose of raising this one was to clearly address and describe the entire issue of Drupal without mod rewrite, and not particular symptoms or whether warning / error messages should be displayed on install etc
I don't believe either the description or the title of #2099311 are likely to result in a fruitful outcome.
I may be wrong but would prefer a consensus on that before closing this one, particularly as this issue has already resulted in the start of a fruitful discussion. It could well peter out and go no-where though, and if #2099311 does similar it won't really matter. I admit that until just now it didn't occur to me that I could change the title of an issue, however would it have been less confusing to rewrite both the title and summary of #2099311 completely from scratch (doesn't seem like good practice to me but I don't have a huge amount of experience in these issues).
Edit: this issue was supposed to reference both #209931 and #2094985 but I may have messed it up when I posted apologies.
Comment #10
chris_hall_hu_cheng commentedTrying to add #2094985 as a related but just failed once, attempting again .... failed, not sure what is going wrong I add the numbers in the related issue box, it even brings up the title but they don't get added to this issue as related??
Comment #11
joelpittetMoving this to a task to emphasis the distinction and re-titling to be more inline with the IS.
Comment #12
13rac1 commented@chris_hall_hu_cheng Please don't be surprised if someone else closes this issue again. #2099311: User login not working if mod_rewrite is not enabled is the original report; the conversation should be expanded there.
Please change it then. You are able to edit the title and entire description of the original issue. Fragmenting the issue queue leads to confusion and slower resolution times.
Comment #13
13rac1 commentedComment #14
quietone commentedInstalled and tested patch #1 with rewrite disabled. Forms are now working with and without rewrite enabled. Thanks chris_hall_hu_cheng.
According to geerlingguy (https://www.drupal.org/node/2094985#comment-9331657) working without clean URLs is a regression so shouldn't the category remain Bug report?
Comment #15
chris_hall_hu_cheng commentedAdding two more tasks identified in the comments:
Comment #16
chris_hall_hu_cheng commentedThis patch should be bit better, have the FallbackResource is only called if mod_rewrite is not enabled, which means that Apache 2.2.16 is only a requirement when rewrite is not present.
Also narrows down the scope of things to think about because on a rewrite enabled server all the rewrite stuff is behaving exactly as before.
I reviewed ErrorDocument and can't see that it is doing anything with this configuration, so took that out too.
Comment #17
alexpottThis definitely fixing a bug.
Comment #18
yesct commentedComment #19
yesct commentedug. I will move as much info as possible to the original issue: #2099311: User login not working if mod_rewrite is not enabled
Comment #20
alexpott@YesCT I've just been reviewing the working patch on this issue...
Manually tested and it works great. Tested 404's with rewrite enabled and disabled. A quick google for IIS and it looks like you can't disable the rewrite so we don't have to worry about web.config.
I'm going to try to write a test.
Now to look through all the dupes and see who deserves credit.
Comment #21
yesct commentedsorry.
ok. let's use this issue since it has the patch, and move any info from the other issue here that is needed.
We can mention and thank the opener of the other issue (@ speely ) on this one. I'll update the summary to do that.
Comment #22
alexpottI think it is okay to raise the minimum requirement for people who want Drupal 8 to run without clean urls to Apache 2.2.16.
I've thought about tests and I can not see how to do this. Therefore all we need to do is:
Once this goes in we should update the requirements page.
Added a suggested commit message of
based on people who worked on #2094985: Drupal 8 install does not warn if Clean Urls are not supported
Comment #23
alexpottThis is the page that needs updating once this is fixed https://www.drupal.org/requirements/webserver
Comment #24
yesct commentedI will start the change record now.
Comment #25
yesct commentedhttps://www.drupal.org/node/2420781 is the draft change record.
Comment #26
joachim commented> improve the code comments to mention the Apache version requirement
I'm not entirely sure what's needed where, but here's a stab at it.
Comment #27
alexpottadded more people to the suggested commit message from #1878884: Drupal8 doesn't warn you if apache rewrite is turned off and @joachim.
Let's make this read more like a sentence.
This should be re-flowed to join up with the previous line.
This is a duplicate comment
I think the comment should be something like:
Comment #28
joachim commentedDone.
Comment #29
joachim commentedOops.
Comment #30
alexpottLooks great. Thanks.
Comment #31
mikeker commentedFollowing pestering in IRC from YesCT (*smirk*), the attached patch fixes the issues in #27. I removed the Apache version requirement phrase because, if this is enabled by default, then 2.2.16 should be Drupal's min Apache version number. If moving the requirements is not in the cards, then this .htaccess directive should be commented out.
@TODO: If this patch is accepted, the requirements page will need to be updated to include the new min Apache version and
will need to be reworded.
Comment #32
mikeker commentedCrap. Totally cross-posted... Sorry about that.
But I think my comments, above, about the min Apache version number are still valid.
Comment #33
yesct commentedinterdiffs++
soooo.
We need to have a requirements check for apache < 2.2.16 AND no rewrite mod enabled.
we can bring over some code from #2094985: Drupal 8 install does not warn if Clean Urls are not supported
also, manually testing on a server with < 2.2.16 would be great.
@jsmith might be able to do that.
Comment #34
mikeker commentedAdding the install check from #2094985-41: Drupal 8 install does not warn if Clean Urls are not supported along with the de-capitalization requested by @alexpott in #2094985-44: Drupal 8 install does not warn if Clean Urls are not supported.
I haven't had a chance to test this and probably won't this evening. I would appreciate someone running through a manual install with/without mod_rewrite enabled and posting back their results. Thanks!
Comment #35
mfbas I mentioned up in #2, to avoid confusion it should be documented that the FallbackResource /index.php directive also requires drupal to be in the top-level directory, not in a subdirectory.
Comment #36
yesct commentedjust to have the testbot run.
Comment #37
yesct commentedThis should be a sentence. (end in a period)
And I think we only want to check this if apache version is < 2.2.16
Can we check that?
Needs work for that and #35
Comment #38
mikeker commentedAdded comment to include #35. Fixed #1 in #37. Not sure about how to do #2 in #37 so I'm leaving that off for now.
Comment #39
mikeker commentedCorrects capitalization of "clean"... Interdiff is against #34.
Comment #40
joelpittetAgain, this is awesome!
Super minor nitpick needs a space after the comma.
Comment #41
mikeker commentedYup.
Comment #42
alexpottI think if we can determine the version from http://php.net/manual/en/function.apache-get-version.php then we should produce a fail if less that 2.2.16 - but we need to keep in mind that apache might not report the exact version depending on how it is set up.
Comment #43
alexpottAdding @mikeker to the suggested commit message.
Comment #44
joelpittet@alexpott that function doesn't exist in the CLI it seems, so that will be only for the UI, is that ok?
Will need to be wrapped in a
function_exists()Would something like this work?
Comment #45
joelpittetPseudo Unit Tested version:P
Comment #46
joachim commented> if (preg_match('/(\d+)\.(\d+)\.?(\d+)?/', $apache_version, $matches)) {
Isn't there a PHP function for comparing version numbers?
Comment #47
joelpittet@joachim I'll say no, cus I looked http://php.net/manual-lookup.php?pattern=version&lang=en&scope=404quickref
Also #45 is better;)
Comment #48
joachim commentedErm, http://php.net/manual/en/function.version-compare.php ?
Comment #49
joelpittet@joachim
my regular expression is trying to parse out a version number out of a random string that comes from Apache Status module... sometimes.
Comment #50
joelpittet@joachim I guess I could use my expression in #45 to get something that
version_compare()can use. Maybe that's what you are trying to say all along?Comment #51
joelpittetWell it didn't pass my pseudo unit test:D
Edit: Fixed results.
but it is simpler:
Comment #52
joelpittetI think #45 is more accurate especially for:
FAIL - Major - Apache/2Comment #53
kattekrab commentedComment #54
thomwilhelm commentedI've been following this issue for a while to see how it progresses, as I got burned on it for quite a while. I noticed that the following page about webserver requirements will need updating as it now doesn't seem to follow the thinking here:
https://www.drupal.org/requirements/webserver
My 2c is that it would just be easier to make clean URL's a requirement in Drupal 8 (as mentioned in the requirements), it seems every fix for this gets messy when checking for edge cases. Following on from a comment made by chris_hall_hu_cheng, it would be great if someone could make a ruling on the direction of this clean url support policy, as it still seems like there is confusion as to whether they should be a requirement or not.
Comment #55
kattekrab commented@joelpittet - did you roll all that into the actual patch?
I'm a bit confused about where this issue is at?
Comment #56
mikeker commentedUpdated todo items in the issue summary and added beta eval. Hopefully that will help clarify where things are at the moment.
The tests @joelpittet added in the comments above (for testing Apache version numbers) have not been rolled into this patch... Yet. :)
Comment #57
mikeker commentedCouple quick comments on things I ran into when trying to update this patch:
apache_get_version()is only available if PHP is compiled for use with Apache. If you're running FastCGI (which a lot of PHP 5.5 users will to take advantage of the new OPCache) it thrown a compile error.version_compare()treats '2.2' as < 2.2.16, but in this case 2.2 could be greater than 2.2.16 -- we just don't know because...$_SERVER['SERVER_SOFTWARE']andapache_get_version()return values are both controlled by the ServerTokens setting in httpd.conf.It seems we need to build a function that returns three values:
0 == Apache version verified to be less than 2.2.16 (not compatible without mod_rewrite)
1 == Apache version verified to be 2.2.16 or greater (compatible without mod_rewrite)
2 == Apache version that might be 2.2.16 or greater but we don't know (???)
And need to present different warnings/errors during install for each. If so, do we treat "Apache/2.2" without mod_rewrite as an install error or just a warning?
We could fix all this if we set the minimum version of Apache to 2.2.16 for Drupal 8, regardless of mod_rewrite. Is that an option? We would still need to present a warning for those servers that report "Apache/2" or similar but it would clarify things a lot.
Comment #58
alexpottGiven that apache_get_version() can return nothing if the ServerTokens is configured for production I think we need to put a warning if mod_rewrite is not enabled and we can't reliably determine apache version. If we can reliably determine that the Apache version does not support FallbackResource and mod_rewrite is not enabled then we need to produce a requirements error.
Comment #59
mikeker commentedOkey dokey...
Tested the conditional logic using a proto-unit-test a la @joelpittet, where the return from test() is
array($rewrite_warning, $rewrite_error).Comment #60
mikeker commentedIt helps to include the files in question...
Comment #62
kattekrab commented@mikeker - thanks for taking this forward! and you too @YesCT for bumping back to test bot.
Comment #65
Crell commentedHow come we can't extract the version number directly and use version_compare()? That would certainly be less code, and easier to read...
Otherwise this seems fine to me.
Comment #66
mikeker commentedRerolled.
@Crell in #65:
Agreed, it's ugly... However, see #57.2 and .3. In short,
version_comparecorrectly treats2.2as less than2.2.16, butServerTokenssettings could have Apache version 2.2.99 return just2.2or2. Thus the need for the yes/no/don't-know comparison.Comment #67
Crell commentedThat's grotesque, Apache... Can we include that in the comment block?
Comment #68
mikeker commentedAdded a comment that Apache's version reporting is grotesque... :)
I beefed up the comment block before that tangle of code and fixed a typo in the text of the warning.
Comment #69
Crell commentedBot should be happy, so let's do. Thanks!
Comment #70
alexpottI think we should have a followup to detect when drupal is being installed in a sub directory and warn if mod_rewrite is not on.
This issue is a major task that will improve performance significantly and the disruption it introduces is limited. Per https://www.drupal.org/core/beta-changes, this is a good change to complete during the Drupal 8 beta phase. Committed 4a34451 and pushed to 8.0.x. Thanks!
Comment #73
kattekrab commentedDid that follow up ever happen?
I was working with someone using Drupal8 for the first time, and we got bit by this issue.
#2761935: Thumbnail image style not being generated when embedded in wysiwyg leaving broken preview
Mod rewrite not on in a VM/docker environment.
A warning in the status report (unfortunately rejected with a "No, works as designed") would have provided a clue, rather than time wasted looking for answers in all the wrong places.
#2094985: Drupal 8 install does not warn if Clean Urls are not supported
I had a vague memory of hitting something similar somewhere, so went looking, and stumbled back on all these issues.
Comment #74
kattekrab commentedComment #75
quietone commentedpublish the cr