Skip to content
Snippets Groups Projects
Commit d9d93892 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #366768 by plach, hass, GiorgosK: translation links link to unpublished translation.

parent 2a3d1886
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -384,7 +384,7 @@ function translation_node_get_translations($tnid) { ...@@ -384,7 +384,7 @@ function translation_node_get_translations($tnid) {
if (!isset($translations[$tnid])) { if (!isset($translations[$tnid])) {
$translations[$tnid] = array(); $translations[$tnid] = array();
$result = db_select('node', 'n') $result = db_select('node', 'n')
->fields('n', array('nid', 'title', 'language')) ->fields('n', array('nid', 'type', 'uid', 'status', 'title', 'language'))
->condition('n.tnid', $tnid) ->condition('n.tnid', $tnid)
->addTag('node_access') ->addTag('node_access')
->execute(); ->execute();
...@@ -435,8 +435,11 @@ function translation_path_get_translations($path) { ...@@ -435,8 +435,11 @@ function translation_path_get_translations($path) {
*/ */
function translation_language_switch_links_alter(array &$links, $type, $path) { function translation_language_switch_links_alter(array &$links, $type, $path) {
if ($type == LANGUAGE_TYPE_INTERFACE && $paths = translation_path_get_translations($path)) { if ($type == LANGUAGE_TYPE_INTERFACE && $paths = translation_path_get_translations($path)) {
$path = explode('/', $path);
$node = node_load($path[1]);
$translations = translation_node_get_translations($node->tnid);
foreach ($links as $langcode => $link) { foreach ($links as $langcode => $link) {
if (isset($paths[$langcode])) { if (isset($paths[$langcode]) && $translations[$langcode]->status) {
// Translation in a different node. // Translation in a different node.
$links[$langcode]['href'] = $paths[$langcode]; $links[$langcode]['href'] = $paths[$langcode];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment