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,
The line below breaks the site when using the site in multi - language mode.
<?php
define('CSHS_DEFAULT_NONE_LABEL', t('- Please select -'));
?>
cshs/cshs.module
Error: "Fatal error: Call to a member function getRequestUri() on null"
Steps to reproduce it:
- Install Drupal in another language than English
- Enable cshs module.
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff-2774919-11-13.txt | 1.02 KB | BR0kEN |
#13 | cshs-fix_localized_constant-2774919-13.patch | 1.55 KB | BR0kEN |
Comments
Comment #2
mpastas CreditAttribution: mpastas at Globant commentedComment #3
mpastas CreditAttribution: mpastas at Globant commentedPatch added.
Comment #4
dagmarIf this default is not used, you could delete it.
check if you can use $this->t() at this stage
Comment #5
mpastas CreditAttribution: mpastas at Globant commentedYou are right Mariano. Patch updated.
Comment #6
mpastas CreditAttribution: mpastas at Globant commentedComment #7
dagmarNice
Comment #8
BR0kENConstant also used in
CshsOptionsFromHelper
.Comment #9
dagmarThanks. Here is the patch.
Comment #10
gngn CreditAttribution: gngn at Computer Manufaktur GmbH commentedJust a tiny thing: #9 changes
CshsOptionsFromHelper
fromto
We should drop the single-quotes to actually translate '- Please select -'.
Although I didn't see 'CSHS_DEFAULT_NONE_LABEL' on my screen - does somecode overwrites the '- Please select -' from
CshsOptionsFromHelper::getOptions()
?Also I'm not sure about using t() with a constant...
Comment #11
dagmarRight. Thanks @gngn.
This is ok, the recommendation is not use variables insde t().
Comment #12
mpastas CreditAttribution: mpastas at Globant commentedPatch updated based on dev version.
Comment #13
BR0kENSince we are passing non string literals as argument for
t()
, but completely sure that value - is a string, then we have to prevent codesniffer warnings using special tags. Also,$this->t()
have to be used wherever possible.Comment #15
BR0kEN