Dynamic properties are deprecated in PHP 8.2

Created on 14 November 2023, about 1 year ago
Updated 30 August 2024, 4 months ago

Problem/Motivation

In PHP 8.2, dynamic properties are deprecated. Several classes in Linkit do not declare all the properties that can be created on them.

Steps to reproduce

  1. Install the latest version of Linkit on a Drupal 7 site.
  2. Configure one or more Linkit profiles.
  3. Export the Linkit profiles to code using Features or a custom module.
  4. Reinstall the site using the Feature or custom module to programmatically set up the profile.
  5. Note the following properties are reported as dynamic:

LinkitProfile::$export_module
LinkitProfile::$export_type
LinkitProfile::$in_code_only
LinkitProfile::$table
LinkitProfile::$type
LinkitProfile::$weight
LinkitProfile::$admin_description
LinkitProfile::$admin_title
LinkitProfile::$api_version
LinkitProfile::$disabled
LinkitProfile::$name
LinkitProfile::$profile_type
LinkitProfile::$weight
LinkitSearchPluginEntity::$unusable

Sample PHP notices in the log:

Creation of dynamic property LinkitSearchPluginEntity::$unusable is deprecated in LinkitSearchPluginEntity->__construct() (line 78 of
/linkit/plugins/linkit_search/entity.class.php).
Creation of dynamic property LinkitProfile::$admin_title is deprecated in eval() (line 7 of /features/features.export.inc(1138): eval()'d code).

Proposed resolution

Add the annotation to allow dynamic properties to these classes. Another solution would be to declare all the properties in the class.
There may be more classes or properties identified at runtime; these are just the ones I found when installing an exported Linkit profile.

Remaining tasks

Patch and test.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

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