When $filter_key is NULL in LanguageSwitcherLinksAlterer::alter(), line 106 uses it as
an array offset ($link['query'][$filter_key]), triggering the PHP 8.5 deprecation:
"Using null as an array offset is deprecated, use an empty string instead".

Steps to reproduce:
1. Run Drupal on PHP 8.5 with Facets enabled
2. Use the language switcher on a page with faceted search
3. Observe the deprecation notice in logs

Expected: No deprecation notice.
Actual: Deprecated function: Using null as an array offset is deprecated in
Drupal\facets\LanguageSwitcherLinksAlterer->alter() (line 106).

Fix: add a $filter_key === NULL guard before the isset() check on line 106 of
src/LanguageSwitcherLinksAlterer.php.

Issue fork facets-3580885

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

paranojik created an issue. See original summary.

paranojik’s picture

Title: Deprecated function: Using null as an array offset is deprecated, use an empty string instead in Drupal\facets\LanguageSwitcherLinksAlterer->alter() (line 106 of modules/contrib/facets/src/LanguageSwitcherLinksAlterer.php). Drupal\facets\LanguageSwitcherL » Deprecated function PHP 8.5: Using null as an array offset is deprecated

  • strykaizer committed e5c23b9b on 3.0.x
    Issue #3580885: PHP 8.5 deprecation: Using null as array offset in...
strykaizer’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • strykaizer committed ce0ad0d6 on 3.0.x
    Issue #3580885: PHP 8.5 deprecation: Using null as array offset in...

  • strykaizer committed a8bf202a on 3.0.x
    Revert "Issue #3580885: PHP 8.5 deprecation: Using null as array offset...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.