Closed (fixed)
Project:
Feeds
Version:
8.x-3.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
4 Jun 2024 at 22:09 UTC
Updated:
19 Sep 2025 at 16:00 UTC
Jump to comment: Most recent
When importing Feeds items via the UI, we see the following error:
Deprecated function: Creation of dynamic property Drupal\feeds\Feeds\Item\SyndicationItem::$parent:fid is deprecated in Drupal\Core\Queue\Batch->claimItem() (line 31 of /var/www/html/html/core/lib/Drupal/Core/Queue/Batch.php)
Install latest Drupal 10.2.6 and Feeds 8.x-3.0-beta4 on PHP 8.2.
Create a Feeds type and a Feed and import it via the UI. Have not tried this via cron.
Make Feeds compatible with latest version of Core Batch API.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
bharath-kondeti commentedComment #5
immaculatexavier commentedComment #6
megachriz'parent:fid' is actually a dynamic property. It is generated in
\Drupal\feeds\Feeds\Source\BasicFieldSource. Besides 'parent:fid', you also have 'parent:uid', 'parent:created', 'parent:title' and many others.So simply declaring $parent_fid as a variable here is not a sustainable solution.
So I think that BaseItem needs to check in methods `get()` and `set()` if the property to set exists. And if not, write to `$data` property like DynamicItem does. I don't know however if there any drawbacks in that approach, but I think the risk for that is low.
Comment #7
bharath-kondeti commentedComment #8
megachrizAlmost. BaseItem should check first if the requested field exists as property in the class. And if not, fallback to the
$dataarray.Comment #9
bharath-kondeti commentedComment #10
bharath-kondeti commented@MegaChriz Tried to fix the review. Please check and do let me know, if anymore changes are needed.
Comment #11
megachrizproperty_exists()should be used in bothBaseItem::get()andBaseItem::set().BaseItem::get()should check if$this->data[$field]exists before returning that.BaseItem::toArray()should merge the object vars with$dataarray and then remove the extra data array from it.Comment #12
bharath-kondeti commentedReverted the blank line code on SyndicationItem.php for failing tests. I will working on the remaining.
Comment #13
ankitv18 commentedReviewed the MR!174 and suggested few changes
cc: @MegaChriz
Comment #16
bkosborneI created a new MR that just tells PHP it's OK to have dynamic properties on the item. This is a simple approach. I'm not sure if this is really the best long term solution.
Comment #17
megachriz@bkosborne
Thanks for your contribution. This could be a viable solution too, though it is possible that it will no longer be supported in a future version of PHP (PHP 9?). I'm not sure yet though if it is going to be removed, it's not clear from https://www.php.net/manual/en/language.oop5.properties.php#language.oop5...
Meanwhile, I've updated the other MR:
Comment #18
baikho commentedTested MR !174 on 3 custom Feeds Importers that extend the BaseItem class.
Works as expected and no PHP deprecation notices now. RTBC for me
This also significantly sped up the batch process.
Comment #19
bwoods commentedAnother confirmation that this patch does the trick. My specs:
Drupal Core 10.4.6
PHP 8.3.20
Feeds v3.0.0
Comment #20
megachrizI adjusted the code a bit, because I did not like that 'data' became a preserved key. The changes ensure that a field called 'data' can be set without overwriting the complete $data property.
I also expanded the test coverage a bit.
AI helped a bit with this.
Comment #22
megachrizI looked through the code one more time, did not spot anything suspicious. Merged it. Thanks all who helped on this issue.
Comment #24
jwilson3Any chance we could get a 3.1 (or 3.0.1) release that includes this fix? This generates a lot of unnecessary noise in logs.
We are seeing deprecation warnings on cron run after updating to PHP 8.3.21 and clearing caches. These are only notice errors, I think, so we should still be fine. But there are about 500 of them after running cron from the admin UI.
Comment #25
terry_kolodiy commentedhttps://git.drupalcode.org/project/feeds/-/merge_requests/174.diff
Works perfect for me.
Thanks!