Subject says it all.
| Comment | File | Size | Author |
|---|---|---|---|
| install-request-uri.patch | 768 bytes | Anonymous (not verified) | |
| #4 | request-uri-226873-4.patch | 585 bytes | drupal_was_my_past |
| #6 | install_request_uri-226873-6.patch | 610 bytes | balintd |
| #7 | request_uri-226873-7.patch | 2.04 KB | denes.szabo |
| #7 | request_uri-226873-7-test-only.patch | 1.44 KB | denes.szabo |
Comments
Comment #1
lilou commentedWhy call
request_uri()instead of$_SERVER['REQUEST_URI']?Comment #2
jgraham commentedI think the documentation for request_uri says it all;
"Since $_SERVER['REQUEST_URI'] is only available on Apache, we generate an equivalent using other environment variables."
Comment #4
drupal_was_my_past commentedRe-roll patch from #1.
Comment #5
xjmLooks good to me. Does this function have unit tests? We could maybe test a few patterns with a dummy
$_SERVER, I guess.Note that the Drupal 8.x patch will need to be rerolled, because the core directory structure for Drupal 8 has now changed. (For more information, see #22336: Move all core Drupal files under a /core folder to improve usability and upgrades). When the patch has been rerolled, please set the issue back to "Needs Review."
Tagging as novice for the task of rerolling the Drupal 8.x patch.
Comment #6
balintd commentedHere is the rerolled patch.
Comment #7
denes.szabo commentedHere is the test for this issue.
Comment #9
denes.szabo commentedFixed test $_SERVER variables in setUp().
Comment #10
xjmAwesome, thanks for the tests! There's a couple minor things with the code style that distracted me a bit:
Should begin "Tests." (Yeah, that's different from the rest of the file, but we're in the process of cleaning it up as a part of #1310084: [meta] API documentation cleanup sprint). ;)
I think we could probably leave off the @see here, since it can be gotten via git blame. Instead, let's remove the quotes and say:
Since $_SERVER['REQUEST_URI'] is only available on Apache,
we usedrupal_detect_baseurl() uses request_uri() to generate an equivalent using other environment variables.Very minor point, but URL should be all in caps.
I'd clarify this a little: "Save original $_SERVER variable." Then, above the next section, add a comment that says something like: "Create a dummy $_SERVER variable for testing."
Teensy bit of trailing whitespace here.
Maybe reword a little to "The detected base URL is valid." Also, we can probably leave off the t(). See #500866: [META] remove t() from assert message.
I'd aslo suggest an inline comment or two in
testValidBaseUrl()to explain what we're doing.If you roll a new patch, could you also re-upload the (new) test-only version just to make it clear that it fails for the "right" reason this time?
Great job on this. Thanks for picking up the issue so quickly. :)
Comment #12
xjmHmm, looks like there's still something else going on. I'll try it locally.
Comment #13
denes.szabo commentedYeah, locally the test ran succesfully. After the first failed server test I tried to set up a test environment similar to real one.
Comment #14
David_Rothstein commentedHate to say this given the work that's already gone into this issue, but for Drupal 8, at least, couldn't we just delete the drupal_detect_baseurl() function entirely? It doesn't seem to be used anywhere in core, and it's hard to see why it would be useful elsewhere since we have $GLOBALS['base_url'] instead...
For Drupal 7 backport I guess we have to keep it, but it might not be worth too much effort getting the tests to work if they're troublesome (if the function is on its way out anyway).
Comment #15
David_Rothstein commentedThat said, I'm guessing the test fails due to this:
That won't work if Drupal is being run in a subdirectory (such as http://localhost/drupal), and it failed for me when I tried it locally because of that... Maybe the testbot runs in a subdirectory also?
Meanwhile the "Undefined index: HTTPS" PHP notice in the tests seems to be a straight-up bug in drupal_detect_baseurl() itself. I'm not sure about the other PHP notices; perhaps they are also.
Comment #16
denes.szabo commentedI agree with you, I have just found one calling the drupal_detect_baseurl() and seem replaceable with $GLOBALS['base_url'].
Comment #17
Ulisse2 commented.
Comment #18
albert volkman commentedIf there's no use for the function, this patch removes drupal_detect_baseurl().
Comment #20
BrockBoland commented#18: request_uri-226873-18.patch queued for re-testing.
Comment #21
kscheirerFor the D7 backport, the patch in #9 needs work but it's a good place to start. #18 seems sane for D8. This counts as an API change in D8, so once this is committed we'll need a change notice as well. Docs on change records.
Comment #22
catchCommitted/pushed to 8.x, thanks!
Comment #23
catchSorry, typed too fast, no longer applies.
Comment #24
longwaveRerolled #18.
Comment #25
catchThanks for the quick re-roll. Actually committed/pushed this time. Back to 7.x for backport.
Comment #26
petermallett commentedI made a port of the patch from #9 for 7.x including the suggested minor changes in #10, I'm assuming this will still fail, but maybe get this moving again.
Comment #27
petermallett commentedComment #28
David_Rothstein commentedComment #30
petermallett commentedLooked at this a bit more this morning, it looks like this function just doesn't do what is intended. Also, it is never called anywhere that I can find in D7 either.
I could have sworn this test was passing for me yesterday, but looking today it is not & it's due to $_SERVER['SERVER_NAME'] not being set. I looked into how $base_url is created in drupal_settings_initialize(), and it is using $_SERVER['HTTP_HOST']; perhaps drupal_detect_baseurl has just been broken/unused for a long time & not noticed?
Comment #31
David_Rothstein commentedAll sorts of issues with this function, apparently.
Comment #34
stefan.r commented