Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The module did not cooperate with internationalization module.
if (module_exists('i18n')) {
if ($path = drupal_get_normal_path($matches[3])) {
if (substr($path, 0, 5) == 'node/') {
$nid = substr($path, 5);
}
}
elseif (preg_match('/(node\/([0-9]+))$/', $matches[3], $match)) {
$nid = $match[2];
}
if (!empty($nid)) {
$languages = language_list('enabled');
$languages = $languages[1];
if (isset($language)) { $url_array['language'] = $languages[i18n_node_get_lang($match[2])];}
$link = url($match[1], $url_array);
}
}
If the first condition passed properly (via drupal_get_normal_path) the second part of the function did not trigger and I got some errors. I changed the function not to use the $match variable and use directly the discovered $nid with "node" prefix.
Also the function i18n_node_get_lang in the latest i18n version uses an obsolete function and results in WSOD with an error. The proper patch is here: #1144914: Node get language cannot use db_result() function.
This thread was created as a follow-up of the thread #945512: Drupal 7 port.
Comment | File | Size | Author |
---|---|---|---|
#1 | error-setting-url-language-1145450-1.patch | 602 bytes | tarmstrong |
pathfilter.module.diff | 762 bytes | kunago |
Comments
Comment #1
tarmstrong CreditAttribution: tarmstrong commentedThe above patch fails if the node corresponding to $nid does not exist. I get this error message:
Here is a patch that does not rely on the node existing.