PHP 8.x compatibility

Created on 28 November 2022, almost 2 years ago
Updated 25 April 2023, over 1 year ago

PHP 8.x deprecation error

A PHP 8.x deprecation error is triggered when saving an override when there is no destination set in the form.

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in src/Form/SearchOverrideForm.php on line 112

Steps to reproduce

  • Open the admin UI.
  • Add new override, save
  • Error is, with default PHP error reporting on, displayed before the user is redirected to the overview.

Error is in following code, $destination is NULL when no destination in the query.

    $destination = \Drupal::request()->query->get('destination');
    if (strpos($destination, 'ajax_form=1')) {
      $is_ajax = TRUE;
    }

Proposed resolution

Replace the line to get the $destination with:

    $destination = \Drupal::request()->query->get('destination', '');
πŸ› Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium zero2one

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.

Production build 0.71.5 2024