- Issue created by @kandugatlasantosh
- ๐บ๐ธUnited States kandugatlasantosh
Issue with the array null check
- ๐ฎ๐ณIndia chetan 11
chetan 11 โ made their first commit to this issueโs fork.
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 1:05pm 19 January 2024 - ๐จ๐ฆCanada No Sssweat
The second patch from #6 introduces
Warning undefined variable $switcher_horizontal_position and $switcher_vertical_position
$float_position = $settings->get('float_position');
Float position will never be an array and will always be a string since you can only select one. Therefore,
if(is_array($float_position)){
Is not necessary and it's introducing the undefined variables as it will never pass this check.
Use the first patch from comment #2 if anything.
I have not been able to reproduce the bug. Might want to add the steps to reproduce.
- ๐ฎ๐ณIndia mdsohaib4242
This worked for me.
// Check if $languages is an array before using array_values() $languages = $settings->get('languages'); if (is_array($languages)) { $languages = array_filter(array_values($languages), function($l) { return !empty($l); }); } else { $languages = []; }
- ๐ฌ๐ทGreece vagelis-prokopiou
This worked for me:
--- ./GTranslateBlock.php 2025-01-19 11:15:27.000725955 +0200 +++ html/modules/contrib/gtranslate/src/Plugin/Block/GTranslateBlock.php 2025-01-19 11:15:54.316640455 +0200 @@ -383,7 +383,7 @@ $url_structure = $settings->get('url_structure'); $custom_domains = $settings->get('custom_domains'); $custom_domains_config = $settings->get('custom_domains_config'); - $languages = array_values(array_filter(array_values($settings->get('languages')), function($l) {return !empty($l);})); + $languages = array_values(array_filter(array_values($settings->get('languages') ?? []), function($l) {return !empty($l);})); $custom_css = $settings->get('custom_css'); $enable_cdn = $settings->get('enable_cdn'); @@ -440,4 +440,4 @@ return $return; } -} \ No newline at end of file +}
Module version: 3.0.4
PHP: 8.3