Download & Extend

Generating nodes with node_save only creates aliases for default language on multilanguage site

Project:Pathauto
Version:7.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

I'm creating nodes from a xml file using node_save in my own script.

My code looks like this:

<?php
$node
= new stdClass();
$node->title = trim($item->title[0]);
$node->type = "job";
$node->language = 'de';
$node->uid = $user->uid;
$node->status = 1;
$node->promote = 0;
$node->comment = 1;
$node->path['pathauto'] = TRUE;
       
$node->body[$language_body][0]['value']   = trim($item->description[0]);
$node->body[$language_body][0]['summary'] = trim(text_summary($item->description[0]));
$node->body[$language_body][0]['format']  = 'full_html';
       
$node = node_submit($node);
       
node_save($node);
?>

Like the issue title suggests I'm working with a multilingual site (en+de).
In the code example I'm creating a german node. The url alias is correctly generated by pathauto using the pattern that i specified for german "job" nodes. As long as the default language is set to german.

If I'm changing the default language to english the code example doesn't work anymore. That is: the node gets created, the alias gets created and saved in the url_alias table. But the redirection from such an alias doesn't work anymore. If I call such an alias i only get a "Page not found" error.

Please help.

Comments

#1

Status:active» closed (works as designed)

When you create a node with a specific langcode, the URL alias gets saved/generated with the same langcode. By design in Drupal core, when you a browsing the site in a specific language, you will only be able to "see" URL aliases of that language or any aliases that are set to 'Language neutral'. This is nothing specific to Pathauto.

You may be interested in subscribing to #1234924: Option to always force language = All?.

nobody click here