Hi there, I was hoping for some quick assistance related to making sure an alias does not get created where one already exists. I am using the migrate module to bring in content and everything works perfectly including the aliases. The problem is during my post import process where I am trying to crawl the generated table that migrate module provides in order to create translation sets. (every two rows has an english and french node)

public function postImport(){
    //Fix Translation ID
    $result = db_query("SELECT destid1 FROM {migrate_map_html_intranet}");
    $currentRowCount = 0;
    $current_translateid = 0;
    foreach ($result as $record) {
      if ($currentRowCount % 2 == 0)
      {
        $node = node_load($record->destid1);
        $node->path['pathauto'] = FALSE;
        //$node->pathauto_perform_alias = FALSE;
        $node->tnid = $record->destid1;
        $current_translateid = $record->destid1;
        node_save($node);
      }
      else {
        $node = node_load($record->destid1);
        $node->path['pathauto'] = FALSE;
        //$node->pathauto_perform_alias = FALSE;
        $node->tnid = $current_translateid;
        node_save($node);
      }      
      $currentRowCount++;
    }
  }

The problem is after this code gets run new aliases get generated and I don't understand why this is as I thought pathauto persistant state would block this from occurring.

Comments

dave reid’s picture

Title: Pathauto Persist Not Working » Does not work when saving entities programatically
Assigned: Unassigned » dave reid

Confirmed that we have a problem when a node is saved programatically that pathauto persist fails to work. I'm working on a test case to confirm/fix.

dave reid’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new0 bytes

Attached patch against 7.x-1.x with a test case.

dave reid’s picture

Status: Needs review » Fixed

Committed #2 to Git: http://drupalcode.org/project/pathauto_persist.git/commit/4228772

Will be included in the upcoming 7.x-1.3 release.

dave reid’s picture

Here was the actual patch.

sylus’s picture

Hey @Dave Reid many thanks for your work on this!

I was a bit confused though about whether I should use:

a) Pathauto + This Module
or
b) Pathauto + Patch as given here: http://drupal.org/node/936222 #77

What do you suggest?

dave reid’s picture

You should continue to use Pathauto + this module until #936222: Merge in pathauto_persist module functionality to prevent losing manual aliases with node_save() calls has been committed to Pathauto. I would not encourage people to be using the patch on a production site until then.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Fixed Code