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 #3328049: PHP 8.2 - Fix deprecated dynamic properties, and the messages are still appearing.
Steps to reproduce
- 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.
- If not using Panopoly, configure a Search API results page.
- Create some content and perform a Search API search using keywords in the content.
- 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.
Comments
Comment #2
cboyden commentedPatch is attached.
Comment #3
larynI'm looking at this in the Backdrop version, where a contributor has made the following comment:
> I don't agree with the fix there. It makes more sense to define property $tags, since it's integral to the functioning of the class.
There is a PR on the issue to do so in Backdrop, which could easily be ported here for Drupal 7 if you agree:
https://github.com/backdrop-contrib/search_api/issues/57
Comment #4
drunken monkeyThanks a lot for reporting this issue, and especially for already providing a patch!
However, I agree with @argiepiano in the Backdrop PR: We should just declare that property, especially if it’s already set in the constructor.
Patch attached, please test/review!
Comment #6
drunken monkeyComment #8
drunken monkeyMerged. Thanks again, everyone!