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
- Install the latest version of Linkit on a Drupal 7 site.
- Configure one or more Linkit profiles.
- Export the Linkit profiles to code using Features or a custom module.
- Reinstall the site using the Feature or custom module to programmatically set up the profile.
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | linkit-dynamic-properties-php82-3401666-2.patch | 673 bytes | cboyden |
Comments
Comment #2
cboyden commentedPatch is attached.
Comment #3
tormiLinked somewhat related issue for visibility.
Comment #4
tormiRTBC
Comment #5
hargobindConfirming that #2 fixes the issue.
The issue was reproducible for me during site cache clear.
Comment #6
danrodPatch #2 worked like a charm to me, thanks a lot !
Thank you !
Comment #8
mark_fullmerThanks, all! I've merged this and cut a new release, 7.x-3.8