Skip to content
Snippets Groups Projects

#3362713: Fix WPOD after NULL result and hide language switcher if empty array or NULL.

Open #3362713: Fix WPOD after NULL result and hide language switcher if empty array or NULL.
Open Jan Kellermann requested to merge issue/drupal-3362713:3362713-11.x into 11.x

Closes #3362713

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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 Pathak
  • The 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.

  • Should a deprecation be thrown is a non array is passed?

  • To be honest: no. In the past the site runs in a wpod and then the empty block was cached. Now the empty block will be cached without the wpod before. But core developers should decide.

  • 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.

  • Please register or sign in to reply
  • Jan Kellermann added 18 commits

    added 18 commits

    Compare with previous version

  • Stephen Mustgrave
  • added 1 commit

    • 1dd5fe46 - Apply 3 suggestion(s) to 3 file(s)

    Compare with previous version

  • Jan Kellermann added 511 commits

    added 511 commits

    Compare with previous version

  • added 1 commit

    • 3cfb9cd3 - Update language_switcher_test.module

    Compare with previous version

  • added 1 commit

    • d3fd4363 - Update language_switcher_test_empty_array.module

    Compare with previous version

  • Jan Kellermann added 19 commits

    added 19 commits

    Compare with previous version

  • Jan Kellermann added 51 commits

    added 51 commits

    Compare with previous version

  • Jan Kellermann resolved all threads

    resolved all threads

  • quietone added 100 commits

    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

    Compare with previous version

  • Stephen Mustgrave
  • Stephen Mustgrave
  • Jan Kellermann added 208 commits

    added 208 commits

    Compare with previous version

  • Jan Kellermann added 6 commits

    added 6 commits

    Compare with previous version

  • added 1 commit

    • a5fa293b - D11: New Hooks Implementation.

    Compare with previous version

  • added 1 commit

    • 49558a68 - Added missing use statements.

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading