Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Feed Me Plugin in Craft CMS: Assets Not Deleting as Expected #1577

Open
DieterVanhove opened this issue Jan 20, 2025 · 3 comments
Labels

Comments

@DieterVanhove
Copy link

Description

I’m encountering an issue with the Feed Me plugin in Craft CMS, and I’m unsure if it's a mistake on my part or a potential bug. Here’s what’s happening:

Steps to reproduce

1.I have an entry that originally includes multiple assets (for example, 3 assets).
2. I then update the same entry, but this time with only 2 assets. These 2 new assets are different from the first 2 assets.
3. When I update the entry using my feed. The first 2 assets update correctly. However, the third asset, which should be deleted (since it's not part of the new feed), remains in the entry.

Additional info

  • Craft version: 4.8.9
  • PHP version: 8.2
  • Database driver & version: Mysql 5.7
  • Plugins & versions:
  • Feed Me: 5.4.0

It seems that the first 2 assets update correctly, but I’m not sure how to ensure the third asset gets removed as intended.

Does anyone know what might be causing this issue, or what I might be missing to ensure the third asset is deleted properly?

@DieterVanhove
Copy link
Author

Hi @engram-design,

Apologies for tagging you—I've noticed your "recent" work on this plugin, so I’m hoping you’re still maintaining it. I’ve found a solution to my problem and would love to know if it could be merged.

I’ve created a fork and made a commit.

The issue is with the EVENT_BEFORE_PROCESS_FEED event in craft\feedme\services\Process.php (line 133). The existingElements are set at that point, but there is no way to modify the query that deletes the asset entries.

I’ve updated the event to include the form element type and attributes, which will also apply any changes made to them.

One potential concern: I’ve changed the $feed from a FeedModel to an array, which could potentially cause issues for other users. However, since other events send an array of form attributes, I followed the same approach. From my testing, I haven’t encountered any problems with the added functionality for modifying the form attributes in EVENT_BEFORE_PROCESS_FEED.

Let me know what you think! I’m open to feedback or suggestions on how to improve this.

Thanks in advance!

@engram-design
Copy link
Contributor

If by "recent" you mean 6 years ago! I've not had anything to do with Feed Me since then.

Not sure if you're aware of the history of Feed Me, but it was originally from Verbb where I created it, but the Craft team took it over. As such, I'm not across the changes that've been made over the last 6 years, so I might not be best placed to answer things properly.

I don't see an issue with your changes at face value, but best to hassle the Craft team about it and ideally make a PR for it. I'm sure they'd be happy to accept it. But yes, changing the variable type for that event would be considered a breaking change.

@DieterVanhove
Copy link
Author

Hi Josh,

Apologies, I didn’t realize that! Thank you for the clarification and your feedback. I’ve gone ahead and created a PR (#1582).

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants