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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 1377666-pathauto-persist-programatic-saving.patch | 6.76 KB | dave reid |
| #2 | 1377666-pathauto-persist-programatic-saving.patch | 0 bytes | dave reid |
Comments
Comment #1
dave reidConfirmed 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.
Comment #2
dave reidAttached patch against 7.x-1.x with a test case.
Comment #3
dave reidCommitted #2 to Git: http://drupalcode.org/project/pathauto_persist.git/commit/4228772
Will be included in the upcoming 7.x-1.3 release.
Comment #4
dave reidHere was the actual patch.
Comment #5
sylus commentedHey @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?
Comment #6
dave reidYou 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.
Comment #7.0
(not verified) commentedFixed Code