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.

Comments

cboyden created an issue. See original summary.

cboyden’s picture

Assigned: cboyden » Unassigned
Status: Active » Needs review
StatusFileSize
new673 bytes

Patch is attached.

tormi’s picture

tormi’s picture

Status: Needs review » Reviewed & tested by the community

RTBC

hargobind’s picture

Confirming that #2 fixes the issue.

The issue was reproducible for me during site cache clear.

danrod’s picture

Patch #2 worked like a charm to me, thanks a lot !
Thank you !

  • mark_fullmer committed 42970d14 on 7.x-3.x
    Issue #3401666 by cboyden, tormi, hargobind, danrod: Dynamic properties...
mark_fullmer’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, all! I've merged this and cut a new release, 7.x-3.8

Status: Fixed » Closed (fixed)

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