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.
i18strings_cache will return an array part of the strings array if objectid is 0 once it has been cached. In i18nstrings_cache the while loop will bail out on !empty($context->objectid) since '0' is considered empty in PHP. I worked around the issue by replacing !empty with isset, but perhaps this has other side effects. Anyhow, I got this bug by using context, the admin module with context inspector and an untranslated title for the locale language switcher block (with block delta 0), so that setup could probably be used to reproduce the bug.
Comments
Comment #1
noomz CreditAttribution: noomz commentedI second @gnucifer, should change to "isset" because objectid can be 0(zero) in any custom module user created. If the purpose is not allow the empty string, I think using "trim" along with "isset" should be better. See in patch.
Comment #2
K15.Multik CreditAttribution: K15.Multik commentedIn my opinion, it is additionally necessary to check whether the value is a number.
Replace
!empty($context->$field)
with(!empty($context->$field) || is_numeric($context->$field))
.Comment #3
K15.Multik CreditAttribution: K15.Multik commentedNeeds review ))
Comment #4.0
(not verified) CreditAttribution: commentedclarification
Comment #5
oliverpolden CreditAttribution: oliverpolden commentedI can confirm I've seen this issue. The patch in #3 works for me.
I've also had a look at the reasons the tests have failed for the patch. I'm not sure exactly how to interpret it but it looks like the test is failing to log in however I've locally tested logging in with a translated block and it works fine.
Comment #6
joseph.olstad