Site aliases do not work for Drupal sites where the drupal root is not at the document root of the web server.

greg.1.anderson - November 6, 2009 - 05:56
Project:Drush
Version:All-Versions-HEAD
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:closed
Description

As I mentioned in #624856: Multisite: How to specify ~/sites/mydomain.com.mysite in the command-line options?, site aliases do not work for sites where the drupal root is in some sub-path rather than directly at the root of the web server. For example, if the drupal site is at http://domain.com/drupal, then the uri is also "domain.com/drupal", but the settings.php file is located in "domain.com.drupal". The site alias code expects that the uri should be located in a folder with the same name as the uri, that is "domain.com.drupal". The fact that the uri is different causes minor problems; however, most things still work.

Similar problems occur if you actually put the 'http://' on the front of the uri in a site alias. This should also be allowed.

I will post a patch to fix this here once I have one ready.

#1

greg.1.anderson - November 7, 2009 - 00:37
Status:needs work» needs review

Patch attached. Makes site aliases work correctly with sites where the site directory might contain a port or path component.

Also, drush sa default will now print out information about the default site -- that is, whichever site is set with -l or --uri. This is useful for setting up site aliases for the first time using --root, --uri and --full. "default" can also be used in other contexts, such as drush sync and drush sql sync.

AttachmentSize
drush-HEAD-2009_11_06.patch 14.16 KB

#2

greg.1.anderson - November 7, 2009 - 14:48

Patch updated.

I realised that "default" should be reserved to mean the default Drush site, so I changed the reserved word to "current" (i.e. drush sa current) to indicate the current site specified by -l / --uri.

AttachmentSize
drush-HEAD-2009_11_07.patch 13.93 KB

#3

moshe weitzman - November 8, 2009 - 03:33

+++ includes/sitealias.inc 7 Nov 2009 14:44:37 -0000
@@ -263,30 +277,82 @@ function _drush_sitealias_build_record_f
+    //$drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT');

lets omit the commented out code

+++ includes/sitealias.inc 7 Nov 2009 14:44:37 -0000
@@ -263,30 +277,82 @@ function _drush_sitealias_build_record_f
+function drush_sitealias_site_dir_from_filename($site_settings_file) {
+  $path = explode('/', $site_settings_file);
+  array_pop($path); // pop off 'settings.php'
+  $site_dir = array_pop($path); // get the directory name that settings.php is in

+  return $site_dir;
+}

looks same as dirname($site_settings_file). am i wrong?

#4

greg.1.anderson - November 9, 2009 - 03:30

1. Whoops. Removed.

2. Almost; it is the same as basename(dirname($site_settings_file)). I changed the implementation to that; the previous implementation was taken from another part of Drush. My favorite kind of code is tested code, but using the platform libraries is even better.

AttachmentSize
drush-HEAD-2009_11_08.patch 14.62 KB

#5

greg.1.anderson - November 9, 2009 - 03:32

The previous patch accidentally included a modified version of the 'drush' script. Use this patch instead.

AttachmentSize
drush-HEAD-2009_11_08.patch 13.73 KB

#6

moshe weitzman - November 9, 2009 - 12:43
Status:needs review» fixed

committed. thx.

#7

System Message - November 23, 2009 - 12:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.