#3362713: Fix WPOD after NULL result and hide language switcher if empty array or NULL.
Closes #3362713
Merge request reports
Activity
418 $language = $link['language'] ?? NULL; 419 if ($language instanceof LanguageInterface) { 420 $this->negotiatedLanguages[LanguageInterface::TYPE_CONTENT] = $language; 421 $this->negotiatedLanguages[LanguageInterface::TYPE_INTERFACE] = $language; 422 } 423 try { 424 return $url instanceof Url && $url->access(); 425 } 426 catch (\Exception) { 427 return FALSE; 428 } 429 }); 430 $this->negotiatedLanguages = $original_languages; 431 432 $links = (object) ['links' => $result, 'method_id' => $method_id]; 416 if ((is_array($result)) && (count($result) > 0)) { Is the $result values are non-array too?
If not then single check of count($result) > 0 is enough
Edited by Ankit PathakThe starting point for the whole issue was the white page of death when hook_language_switch_links_alter() returns a type other than array. So it is mandatory to check the type at this point. We could replace with empty() - but then a wrong string could lead to a WPOD again. The type for the parameter has not yet been defined, this will be done with the MR (see language.api.php) - but for reasons of backward compatibility I would still query the type. I would therefore leave it exactly as it is.
Module code should be be changing the type of $results - this is extremely wrong because if there are multiple alters then it will break if the one alter changings the type and then the next alter is called.
I feel like this issue might be working around a bug in custom code or a contrib module. Obviously the code used to work because we didn't have any code that assumed $result was an array anywhere until the security issue came and made a fix.
Therefore I think we should definitely trigger a recoverable error here if $results is no longer an array.
added 18 commits
-
914a7d8c...ef97485d - 17 commits from branch
project:11.x
- 2925408a - Merge branch drupal:11.x into 3362713-11.x
-
914a7d8c...ef97485d - 17 commits from branch
- Resolved by Jan Kellermann
- Resolved by Jan Kellermann
- Resolved by Jan Kellermann
- Resolved by Jan Kellermann
added 511 commits
-
1dd5fe46...738036cc - 510 commits from branch
project:11.x
- f12400a9 - Merge branch drupal:11.x into 3362713-11.x
-
1dd5fe46...738036cc - 510 commits from branch
added 1 commit
- d3fd4363 - Update language_switcher_test_empty_array.module
added 19 commits
-
d3fd4363...1c773fed - 18 commits from branch
project:11.x
- 20634ccd - Merge branch drupal:11.x into 3362713-11.x
-
d3fd4363...1c773fed - 18 commits from branch
added 51 commits
-
20634ccd...78ec304c - 50 commits from branch
project:11.x
- 25a259fa - Merge branch drupal:11.x into 3362713-11.x
-
20634ccd...78ec304c - 50 commits from branch
added 100 commits
-
25a259fa...e2b97e56 - 95 commits from branch
project:11.x
- 16bee97e - #3362713: Fix WPOD after NULL result and hide language switcher if empty array or NULL.
- 455f1577 - Apply 3 suggestion(s) to 3 file(s)
- a74c96a3 - Update language_switcher_test.module
- 8b443bb9 - Update language_switcher_test_empty_array.module
- 8d9a68cb - improve comments
Toggle commit list-
25a259fa...e2b97e56 - 95 commits from branch
- Resolved by Jan Kellermann
- Resolved by Jan Kellermann
added 208 commits
-
8d9a68cb...70cfbbe0 - 207 commits from branch
project:11.x
- 61acc848 - Merge branch drupal:11.x into 3362713-11.x
-
8d9a68cb...70cfbbe0 - 207 commits from branch
added 6 commits
-
61acc848...9ef9b0f7 - 5 commits from branch
project:11.x
- 5e05a1f7 - Merge branch drupal:11.x into 3362713-11.x
-
61acc848...9ef9b0f7 - 5 commits from branch