When I migrated a site from one url to another, the old alias wasn't deleted. (hosting/c/

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

helmo’s picture

This could be seen as a positive feature. Even after migrating a site old links remain functional.

The hosting_migrate_post_hosting_migrate_task() function saves a new new context which in turn saves a new url_alias.
We could make it check and clean up the old one.

It becomes a problem ones you want to re-use the old site name.
E.g migrate example.com to old.example.com, then new.example.com to example.com.
The second migrate task gives an error on "WD path: The alias 'hosting/c/example.com' for path 'node/42' (language '') was not created, because the path 'node/24' already has the same alias."

So maybe we should check and overwrite...

helmo’s picture

I guess it would be fixed by this oneliner... completely untested though.

diff --git a/hosting.module b/hosting.module
index 13bf3f3..53d3272 100755
--- a/hosting.module
+++ b/hosting.module
@@ -881,6 +881,7 @@ function hosting_context_register($nid, $name) {
   // because we do not want the overhead of having all the
   // path UI stuff on nodes.
   require_once("./modules/path/path.module");
+  path_set_alias(NULL, "hosting/c/$name");
   path_set_alias("node/$nid", "hosting/c/$name");
 }
 
anarcat’s picture

Status: Active » Needs review
helmo’s picture

I've tested this manually today with a drush php-eval.
Seems to work ok.

helmo’s picture

Project: Hostmaster (Aegir) » Hosting
Version: 6.x-2.0-rc5 » 7.x-3.x-dev
FileSize
488 bytes

Patch for 7.x-3.x

helmo’s picture

And some cleanup with comments.

New D6 and D7 patch.

  • helmo committed 273fa38 on 6.x-2.x
    Issue #2163525 by helmo | daften: Fixed Aegir doesn't delete old alias...

  • helmo committed bb50304 on
    Issue #2163525 by helmo | daften: Fixed Aegir doesn't delete old alias...
helmo’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

daften’s picture

Thanks again, sorry for the non-communication, it was buried deep in my inbox and resurfaced now.