Scenario:

1) site exists called www.example.com.

It has an alias example.com that is also Redirected to www.example.com

2) Clone www.example.com and call the new cloned site dev.example.com

Effect: dev.example.com clones all settings including the alias + redirection, and adds them to the vhost. Since the subdomain comes first before www, the dev site is the one that requests to 'example.com' start redirecting to.

I propose that clones of a site do not inherit settings such as aliases, because like the main URL, site aliases should be unique to a specific site.

Comments

Anonymous’s picture

So I've no problem exposing the site alias form fields to the clone form (well, which is really migrate form, and since it's a confirm form, there's no sane form_id to condition on in the alias module's implementation of hook_form_alter, so I duplicated the two form fields).

And I configured the hosting_clone.drush.inc to pass the alias and redirection as options to the backend, and made the backend aware of it.

But cloned sites continue to use the original site's aliases and not the clone's. Then I discovered it's because on insert of a site node, we immediately save the hosting_site_alias data, and that is how in hosting_alias.drush, we are able to do this:

      $task->options['aliases'] = implode(",", hosting_alias_get_aliases($task->ref));
      $task->options['redirection'] = db_result(db_query("SELECT redirection FROM {hosting_site_alias} WHERE vid=%d", $task->ref->vid));

We can reference $task->ref because the site nid exists in the db already. In the case of Clone, the new cloned site doesn't yet on submission of the Clone form: it is only on completion of the Clone task in the queue, that the new site is inserted into the database, so we can't use the same options here because $task->ref in the case of the new clone doesn't exist: or rather, this value is the nid of the site we are making a clone of, and hence why the original site's aliases are used instead.

Unsure how to work around this.

anarcat’s picture

Priority: Critical » Normal
Status: Active » Needs work

I have implemented a workaround for this that simply deletes the site aliases when deploying the site. mig5 has started working on a more complete fix in git:

http://git.mig5.net/?p=modules/provision/.git;a=tree;h=refs/heads/595494...
http://git.mig5.net/?p=modules/hosting/.git;a=tree;h=refs/heads/595494_c...

.. but it's not actually working yet, probably because of a fix similar to the hotfix I just committed: http://drupal.org/cvs?commit=278440

Since this won't break sites anymore, i'm downgrading this to normal.

Anonymous’s picture

So I have this working a lot better now in those git branches, now that I persist aliases in the post deploy task, the new site keeps its new aliases (correctly writes them to drushrc.php). A couple problems still remain

1) Getting a php argument warning in the clone task :

Loading drushrc "/var/aegir/drupal-6.14/sites/29.mig5-forge.net/drushrc.php" into "site" scope.
Undefined index: profiles
array_keys(): The first argument should be an array
Undefined index:
array_merge(): Argument #2 is not an array
Undefined index: modules
Invalid argument supplied for foreach()
Could not remove symlink for alias www.3.mig5-forge.net
Created symlink for alias www.29.mig5-forge.net

Should be able to sort this out.

Note the last two lines: this is the other problem. This deploy command:

function drush_provision_drupal_provision_deploy($url) {
  _provision_drupal_maintain_aliases($url);
}

the function deletes the symlink for the original site and creates it for the target site. Commenting the maintain_aliases function stops it from happening, without losing any functionality, but it's obviously here for a reason.

Anonymous’s picture

Status: Needs work » Needs review

I've actually fixed this and have it working.

git remote add mig5 git://git.mig5.net/drupal/modules/hosting
git remote add mig5 git://git.mig5.net/drupal/modules/provision

(for both:)
git checkout -b 595494_clone_alias mig5/595494_clone_alias

http://git.mig5.net/?p=modules/hosting/.git;a=tree;h=refs/heads/595494_c...
http://git.mig5.net/?p=modules/provision/.git;a=tree;h=refs/heads/595494...

I'm also not convinced that anarcat's fix of resetting the aliases on the invoke of provision deploy would have worked as a stopgap here, because _provision_drupal_maintain_aliases($url) still manages to call the old aliases from the site context (still confused by all this but reading a bit deeper into drush api). I had to set this in that function prior to where it calls _provision_drupal_delete_aliases($url)

    drush_set_option('aliases', drush_get_option('aliases'), 'site');

and some funky stuff to deal with an array of multiple aliases.

*Please* review.

anarcat’s picture

Version: 6.x-0.4-alpha1 » 6.x-0.4-alpha2

I have tested the patch, but I got into such a SNAFU that I can't confirm whether or not the patch actually works. I will have to do other tests.

I have rolled a patch in my production branch that should (almost, it depends on #485646: Site migration fails on multiple SQL servers) apply on alpha2. See: http://git.koumbit.net/?p=drupal/modules/provision/.git;a=commitdiff;h=d...

Anonymous’s picture

Status: Needs review » Fixed

I've committed my fix, please open a new ticket if there are issues.

Status: Fixed » Closed (fixed)

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

anarcat’s picture

Status: Closed (fixed) » Needs work

I *think* this is still an issue. #683804: Cloning site takes over generic alias symlink is a good example that occurs with *automatic* aliases (as opposed to the ones explicitely defined in the site node).

We're running alpha2 with the patch applied, as mentionned above.

anarcat’s picture

anarcat’s picture

Assigned: Unassigned » anarcat

Taking a look at this.

anarcat’s picture

Status: Needs work » Closed (fixed)

Having this issue reopened is too confusing for everyone, I'll followup in #683804: Cloning site takes over generic alias symlink.