Compatibility with last Title dev code

Created on 17 November 2015, about 9 years ago
Updated 3 February 2025, about 23 hours ago

If you use the dev version of Title, or the latest stable version patched with https://www.drupal.org/node/1269076#comment-7169370 , the title will always be the one for the original language of the node.

This is because of this part of Title's code:

  // If Entity Translation is enabled and the entity type is transltable,we need
  // to check if we have a translation for the current active language. If so we
  // need to synchronize the legacy field values into the replacing field
  // translations in the active language.
  if (module_invoke('entity_translation', 'enabled', $entity_type)) {
    $langcode = title_active_language();
    ...
  }
  // Perform reverse synchronization to retain any change in the legacy field
  // values. We must avoid doing this twice as we might overwrite the already
  // synchronized values, if we are updating an existing entity.
  if ($langcode) {
    title_entity_sync($entity_type, $entity, $langcode, TRUE);
  }

To fix it, I added

// Needed because of https://www.drupal.org/node/1269076#comment-8879381
  if (module_exists('title')) {
    $active_language = title_active_language();
    $title = isset($titles[$active_language]) ? $titles[$active_language] : $titles[LANGUAGE_NONE];
  }

just after $title = isset($titles[$entity_language]) ? $titles[$entity_language] : $titles[LANGUAGE_NONE]; in auto_entitylabel_set_title().

I do not provide a patch as Title's code might change again before a new stable version.

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇫🇷France GaëlG Lille, France

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024