Warning: Attempt to read property "links" on null

Created on 22 December 2021, almost 3 years ago
Updated 16 March 2023, over 1 year ago

Warning: Attempt to read property "links" on null in Drupal\dropdown_language\Plugin\Block\DropdownLanguage->build() (line 147 of modules/contrib/dropdown_language/src/Plugin/Block/DropdownLanguage.php).

(On old versions of PHP this is just a notice.)

And then other warnings and even a type error down the line...

Original report:
Notice: Trying to get property 'links' of non-object in Drupal\dropdown_language\Plugin\Block\DropdownLanguage->build() (line 128 of modules/contrib/dropdown_language/src/Plugin/Block/DropdownLanguage.php).
Warning: Invalid argument supplied for foreach() in Drupal\dropdown_language\Plugin\Block\DropdownLanguage->build() (line 167 of modules/contrib/dropdown_language/src/Plugin/Block/DropdownLanguage.php).
Warning: count(): Parameter must be an array or an object that implements Countable in Drupal\dropdown_language\Plugin\Block\DropdownLanguage->build() (line 222 of modules/contrib/dropdown_language/src/Plugin/Block/DropdownLanguage.php).

🐛 Bug report
Status

Closed: duplicate

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇱Netherlands Eric_A

    I'll provide a patch that works on both current PHP and PHP 7.4.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇳🇱Netherlands Eric_A

    No interdiff. Different (but easy to grok) approach. Really small patch.

  • Status changed to Closed: outdated over 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    I think we should close this outdated and instead handle the other follow-up issues to prevent confusion.

    @SKAUGHT please test with Drupal 9.5 and Drupal 10.

  • Status changed to Needs review over 1 year ago
  • 🇳🇱Netherlands Eric_A

    I think we should close this outdated and instead handle the other follow-up issues to prevent confusion.

    @Anybody, thanks for looking into this.

    What follow-up are you referring to? (As far as I can see 🐛 ->getname() is called on $link['language'] = NULL Closed: duplicate is not related at all.)

    In fact, with the fix for SA-CORE-2023-003 in Drupal 9.5.5/10.0.5 it may even be more relevant to get #17 in to fix the warning and accompanying type errors for people on current PHP.

  • 🇩🇪Germany Anybody Porta Westfalica

    Thanks @Eric_A. See 🐛 [META] Fix issues (from Drupal Core change in 9.4.x) Fixed . If you disagree, we should leave this open, could you then please elaborate what exactly has to be done in this issue? Perhaps I got it wrong...

  • Status changed to Closed: duplicate over 1 year ago
  • 🇳🇱Netherlands Eric_A

    Thanks, @Anybody.

    Turns out my patch is kind of a duplicate of the latest merge request in 🐛 Incorporate Drupal 9.4 core changes to getLanguageSwitchLinks Fixed , which currently really has an outdated title...

Production build 0.71.5 2024