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.
Hi all.
I got this error when i tried to view unpublished node (with different language)
In the Translation module, in the hook_language_switch_links_alter there is wrong class assignment
in translation.module, line 531
i've just change
$links[$langcode]['attributes']['class'] = 'locale-untranslated';
to
$links[$langcode]['attributes']['class'][] = 'locale-untranslated';
Comment | File | Size | Author |
---|---|---|---|
#14 | 1408636-translation-attributes-class-array-14.patch | 1.27 KB | c31ck |
#12 | 1408636-translation-attributes-class-array-12-D7.patch | 1.27 KB | c31ck |
#11 | 1408636-11.patch | 1.31 KB | swentel |
#9 | 1408636-9.patch | 1.31 KB | swentel |
#6 | 1408636-6.patch | 639 bytes | swentel |
Comments
Comment #1
c31ck CreditAttribution: c31ck commentedAlthough I'm unable to reproduce the fatal error, the current code in translation.module is indeed not correct. The language switch links get themed by theme_links() and theme_links() expects an array for the class value.
Comment #2
c31ck CreditAttribution: c31ck commentedSetting status to needs review.
Comment #4
c31ck CreditAttribution: c31ck commentedTests are probably using the CSS classes. Since attribues['class'] is now an array, some links will get an extra 'language-link' class. I'll look into that.
Comment #5
kafitz CreditAttribution: kafitz commentedI have the same problem as described.
I think that Patch 1408636-translation-attributes-class-array-1.patch is a good patch. c31ck has described that the patch failed testing because attributes['class'] is now an array. Following code in translations.test triggers the failures:
$xpath = '//div[contains(@class, :type)]//span[@class="locale-untranslated"]';
Comment #6
swentel CreditAttribution: swentel commentedTrying this one, passes tests locally fine.
Comment #7
c31ck CreditAttribution: c31ck commentedYes, that one will probably pass the tests, but it doesn't respect any classes that have already been set on the link. Is that the behaviour we want here?
Comment #8
swentel CreditAttribution: swentel commentedHmm, you're right, let me try again locally.
Comment #9
swentel CreditAttribution: swentel commentedOk, better patch + test fixing
Comment #10
mr.baileysSince we no longer replace all classes with "locale-untranslated", but rather add it as an additional class, this could still fail if classes other than language-link are added, no?
What about
-18 days to next Drupal core point release.
Comment #11
swentel CreditAttribution: swentel commentedAbsolutely right, better patch.
Comment #12
c31ck CreditAttribution: c31ck commentedLooks great. Setting to RTBC based on #5, #10 and my own review.
Adding a D7 patch.
Comment #13
Dries CreditAttribution: Dries commentedI agree that this is a bug. Committed to 8.x. Moving to 7.x for backporting.
Comment #14
c31ck CreditAttribution: c31ck commentedPatch for D7.
Comment #15
Rar9 CreditAttribution: Rar9 commentedPatch #14 also works for 7.12 :-)
Comment #16
C. Lee CreditAttribution: C. Lee commented#14 works. Considering the simplicity of the patch, it seems safe to mark it as reviewed.
Comment #17
vasikei can confirm both : the bug and the solution #14.
Comment #18
webflo CreditAttribution: webflo commented#14 works fine. Please commit this patch. Related issue in i18n issue queue: #1406594: Fatal error: [] operator not supported for strings in includes/common.inc on line 2320.
Comment #19
webchickCommitted and pushed to 7.x. Thanks!
Comment #20
xjm#1450298: Error locale-untranslated in translation module / hook language_switch_links_alter was marked as a duplicate of this issue.
Comment #21
batigol CreditAttribution: batigol commentedThx guys ! A hour ago this error hit me. Good to know it's ALREADY fixed :)
Comment #23
husumiao-1 CreditAttribution: husumiao-1 commentedIt's cool. 1408636-9.patch is worked.
Comment #24
gunwald CreditAttribution: gunwald commentedI get the same error on all user pages for anonymous users:
»user«,
»user/register«, etc
I applied the patch in #14, but this patch did not solve my problem completely. Know the »user« site seems to work but not the other sites like »user/register« etc.
I do not get any further reports (on admin/reports/dblog). Don't know how to debug. What could I do?
post scriptum: Know I figured out, that the issue's cause are these lines in one of my custom modules:
The link creation is wrong, must be:
I'am sorry to bother you, was my fault!