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?

CommentFileSizeAuthor
#2 743368_default_fallback.patch715 bytesalex_b
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greg.1.anderson’s picture

Category: bug » support
Status: Active » Fixed

You 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).

alex_b’s picture

Component: Code » Documentation
Category: support » task
Status: Fixed » Needs review
FileSize
715 bytes

#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.

greg.1.anderson’s picture

Ah, 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...

Owen Barton’s picture

I 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).

alex_b’s picture

FWIW, 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.

greg.1.anderson’s picture

I 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.

alex_b’s picture

Status: Needs review » Reviewed & tested by the community

RTBC then?

greg.1.anderson’s picture

Status: Reviewed & tested by the community » Fixed

Sounds good to me. Committed; thanks.

greg.1.anderson’s picture

Status: Fixed » Needs review

I will also mention that this topic comes up in #520876: list modules in use in multi-site install (API support?).

greg.1.anderson’s picture

Status: Needs review » Fixed

Didn't mean to change the status...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

donquixote’s picture

Status: Closed (fixed) » Needs work

Hi,
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.

moshe weitzman’s picture

Status: Needs work » Closed (fixed)

You fix that by passing --uri option and you can set that in a drushrc.php in order to make it permanent.

donquixote’s picture

drushrc.php sounds ok to me.

donquixote’s picture

Just asking, could the same be done in settings.php instead of drushrc?

Anybody’s picture

Status: Closed (fixed) » Needs work

Hi,

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?

greg.1.anderson’s picture

Version: » 8.x-6.x-dev
Status: Needs work » Closed (won't fix)
Issue tags: +Needs migration

This 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.

Anybody’s picture

Status: Closed (won't fix) » Closed (duplicate)