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.
I sometimes get this warning error:
warning: Illegal offset type in isset or empty in \modules\addresses\addresses.settings.inc on line 293.
This is because of (sometimes) the $_GET['language']
is not usually a string ("en"), but an array like this:
(Array, 2 elements)
0 (String, 2 characters ) en
1 (String, 2 characters ) en
So you should check for if it is an array or not.
My fix:
Original:
// Keep the same language between calls so that t() calls work as expected
if (!empty($_GET['language'])) {
$languages = language_list(); // get all languages
if (isset($languages[$_GET['language']])) {
$language = $languages[$_GET['language']];
}
}
Replaced by:
// Keep the same language between calls so that t() calls work as expected
if (!empty($_GET['language'])) {
$languages = language_list(); // get all languages
$GET_language = is_array($_GET['language']) ? $_GET['language'][0] : $_GET['language'];
if (isset($languages[$GET_language])) {
$language = $languages[$GET_language];
}
}
Comments
Comment #1
trungonly CreditAttribution: trungonly commentedThis is for the latest 6.x-1.x-dev.
Comment #2
AlexisWilke CreditAttribution: AlexisWilke commentedAny particular reasons why it would become an array? Could it be for users who have more than one language listed in their browser?