Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The site URI ($GLOBAL['base_url']) is set to http://default if not further specified with the -l option. Functionality that relies on a properly set base URL fails.
Is this expected?
Comment | File | Size | Author |
---|---|---|---|
#2 | 743368_default_fallback.patch | 715 bytes | alex_b |
Comments
Comment #1
greg.1.anderson CreditAttribution: greg.1.anderson commentedYou must specify which site you want drush to operate on, either by specifying the -l option, or by setting your cwd to a folder inside the site you are operating on, or by specifying an alias for the site. If you do not, drush will check to see if you have a site called 'default' that appears to be configured. If you do, it will try to use it. If you don't want drush to operate on 'default', then delete it, or be sure to specify which site you want to operate on (really I should say AND, because deleting default won't help drush find the site you mean, it will only clear up the error that is confusing you).
Comment #2
alex_b CreditAttribution: alex_b commented#1 - yeah. What I did not expect was merely the fact that $base_url is set to http://default when drush falls back to the default configuration. I've added a note to README.txt.
Comment #3
greg.1.anderson CreditAttribution: greg.1.anderson commentedAh, I see, yes; 'default' is the correct site folder for you, but if -l is not specified, then Drush has nowhere to get the correct base url, because the web server gets this from the http request, which drush is simulating...
Maybe your original comment is correct, and Drush should not select 'default' unless it also has a --uri / -l to correctly set the base url. Leaving this open for others to weigh in...
Comment #4
Owen Barton CreditAttribution: Owen Barton commentedI think using the faux http://default URI it preferable to forcing users to specify a URI even for platforms that only use the "default" site folder. Apart from the lack of documentation causing some confusion (which should be fixed of course) I don't think using this URI has caused any practical problems on most sites, and I can't think of many cases where that would happen (a site making trying to make http calls back to itself from php, perhaps).
Comment #5
alex_b CreditAttribution: alex_b commentedFWIW, it happened to me when doing a web service call that requires a verifying callback to Drupal. In this case the generated callback URL was http://default/feeds/ as opposed to http://example.com/path . The modules I used where Feeds and some custom modules.
I'm personally fine with simply documenting this caveat and leaving functionality as-is.
Comment #6
greg.1.anderson CreditAttribution: greg.1.anderson commentedI think it might also work to put '127.0.0.1 default' in your /etc/hosts file. Does that make Feeds work right for you? If so, it might be worth noting that workaround in the README file as well.
Edit: Actually, scratch that suggestion. If the module is doing an http request, you'd need an appropriate virtual host directive in your web server to map from http://default to the Drupal root. Better to just use -l. I'd say that the above patch is probably the best option.
Comment #7
alex_b CreditAttribution: alex_b commentedRTBC then?
Comment #8
greg.1.anderson CreditAttribution: greg.1.anderson commentedSounds good to me. Committed; thanks.
Comment #9
greg.1.anderson CreditAttribution: greg.1.anderson commentedI will also mention that this topic comes up in #520876: list modules in use in multi-site install (API support?).
Comment #10
greg.1.anderson CreditAttribution: greg.1.anderson commentedDidn't mean to change the status...
Comment #12
donquixote CreditAttribution: donquixote commentedHi,
the http://default shows up e.g. on "drush uli" (drush user-login).
It would be great if we could specify a default "canonical" base url somewhere in Drupal, and let drush use that.
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedYou fix that by passing --uri option and you can set that in a drushrc.php in order to make it permanent.
Comment #14
donquixote CreditAttribution: donquixote commenteddrushrc.php sounds ok to me.
Comment #15
donquixote CreditAttribution: donquixote commentedJust asking, could the same be done in settings.php instead of drushrc?
Comment #16
AnybodyHi,
isn't it possible to use the $base_url set in "default/settings.php" by default, if --uri=default or no such parameter is set?
I think this would make a lot of sense and reduce code duplication?
Comment #17
greg.1.anderson CreditAttribution: greg.1.anderson commentedThis issue was marked
closed (won't fix)
because Drush has moved to Github.If desired, you may copy this task to our Github project and then post a link here to the new issue. Please also change the status of this issue to
closed (duplicate)
.Please ask support questions on Drupal Answers.
Comment #18
AnybodyMoved to GitHub!
https://github.com/drush-ops/drush/issues/87