Dynamic properties are deprecated in PHP 8.2

Created on 16 November 2023, about 1 year ago
Updated 6 January 2024, 12 months ago

Problem/Motivation

In PHP 8.2, dynamic properties are deprecated. At least one class in Search API does not declare all the properties that can be created on its instances.

I've tested this on a site with the latest PHP 8.2 updates/patches for Entity API including πŸ“Œ PHP 8.2 - Fix deprecated dynamic properties Fixed , and the messages are still appearing.

Steps to reproduce

  1. Install the latest versions of Search API and its dependencies on a Drupal 7 site running on PHP 8.2. Panopoly distro works for this.
  2. If not using Panopoly, configure a Search API results page.
  3. Create some content and perform a Search API search using keywords in the content.
  4. Note this message in the logs:

Deprecated function: Creation of dynamic property SearchApiQueryFilter::$tags is deprecated in SearchApiQueryFilter->__construct() (line 1022 of /search_api/includes/query.inc).

Proposed resolution

Add the annotation to allow dynamic properties to the class. Another solution would be to declare all the properties in the class.

Remaining tasks

Patch and test.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

General code

Created by

πŸ‡ΊπŸ‡ΈUnited States cboyden

Live updates comments and jobs are added and updated live.
  • PHP 8.2

    The issue particularly affects sites running on PHP version 8.2.0 or later.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024