I was tempted to put this in #624088: Mapper: ImageField/FileField (formalize feed elements), but since it is committed I created a new issue.

I was previously using #19 from that issue, and I moved today to start using the committed version from HEAD with the batch patch from #600584: Use Batch API. I'm now getting this:

[Fri Jan 15 22:08:11 2010] [error] [client 1.2.3.4] PHP Fatal error:  Class 'FeedsEnclosure' not found in /mypath/sites/all/modules/feeds/mappers/filefield.inc on line 56, referer: http://mysite.com/batch?op=start&id=80

My feed is attached to a content type called feed, refresh never, import on create. Fetcher is file upload, parser is a custom XML parser I wrote based on the OPML parser, and my processor is the node processor. The above message appears when I am on a node of type feed and click on "import" to start the batch processing.

It looks like the class FeedsEnclosure was added in #28. I'm not quite sure yet why it is breaking. I'll report back if I figure it out, but perhaps someone else has a thought. Thanks.

CommentFileSizeAuthor
#4 686462-4_move_feeds_enclosure.patch5.34 KBalex_b

Comments

rjbrown99’s picture

Title: Filefield mapper: Class 'FeedsEnclosure' not found » Custom: Class 'FeedsEnclosure' not found

Ok, so I copied the entire FeedsEnclosure class into my custom XML parser, and now I'm in business. I guess this is my error.

Is it possible to locate FeedsEnclosure somewhere that it can be found when using your own parser?

rjbrown99’s picture

Status: Active » Fixed
rjbrown99’s picture

Status: Fixed » Active

Hm, well maybe that isn't the ideal approach. Now I get this when switching back to the syndication parser -

[Sat Jan 16 12:37:45 2010] [error] [client 1.2.3.4] PHP Fatal error:  Cannot redeclare class FeedsEnclosure in /mypath/sites/all/modules/feeds/plugins/FeedsSyndicationParser.inc on line 63, referer: https://mysite.com/admin/build/feeds/edit/test/parser

Any suggestions? If FeedsEnclosure is a valuable class to supporting modules, would it be better to locate it somewhere that all of the parsers could have access to?

alex_b’s picture

Title: Custom: Class 'FeedsEnclosure' not found » Move FeedsEnclosure class to FeedsParser.inc
StatusFileSize
new5.34 KB

The FeedsEnclosure class is defined in FeedsSyndicationParser with the assumption that only Syndication parsers would use the enclosure element. FeedsSimplePieParser uses a trick to include the file - see how the plugin declaration in feeds.plugins.inc specifies FeedsSyndicationParser as parent while it is actually derived from FeedsParser?

What we *should* do is this: simplify. Let's move FeedsEnclosure to FeedsParser and we don't need to do confusing tricks that trip up developers. Also, in the meantime FeedsDateTimeElement has been committed to FeedsParser.inc. It is only consistent to also capture FeedsEnclosure there.

Patch (untested) attached.

arski’s picture

Brilliant! I just mentioned this issue in #624088 and it works perfectly now. I was trying to create some nodes by importing a .cvs file with image fields.

Thanks!

alex_b’s picture

Priority: Normal » Critical

Let's get this patch into the next release.

alex_b’s picture

Status: Active » Fixed

Committed to HEAD.

Status: Fixed » Closed (fixed)

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