Mentioned here: #705872: HTTPFetcher autodiscovery, it seems a little odd to keep it as one class. It essentially is a two mode class, one is 'file mode' and the other is 'url mode'. I purpose:
1.) FeedsImportBatch becomes abstract
2.) all methods that do an (if ($this->url) { Do X} elseif ($this->file_path) {do Y} become abstract methods
3.) create two classes FeedsImportBatchUrl and FeedsImportBatchFile

Comments

Scott Reynolds’s picture

Status: Active » Needs review
StatusFileSize
new5.56 KB

Attach is a patch. There is a strange field of the FeedsBatchImporter $this->file and its only used in getURL(). I ported it over as is into the FeedsBatchImportFile class.

FeedsBatchImportUrl probably needs

protected $file_path;

For semantics and to keep that from being a 'public' property. Just didn't feel like re rolling.

And should consider doing a try/catch around $this->import. Maybe in that case $this->raw gets set to FALSE. That way when FeedsBatchImportURL won't cause multiple HTTP requests to a bad URL.

fereira’s picture

What are the chances that this patch will get committed?

To me, it seems like to make FeedsImportBatch as an abstract class, because as it is now it assumes that the feed is coming from either or URL or a File. In my case, I am consuming a feed from another module (sparql) and could see creating an FeedsImportBatchFunction class which did an override of the import function such that it called a function (perhaps via module_invoke()) from another module to set the "raw" content.

alex_b’s picture

#2: you would rather create a FeedsImportSparql class than trying to make this generic.

I really would like to get this patch committed. Need to carve out some time for review though. Recent commit of Batch API might collide with this patch btw. Does it still apply?

Scott Reynolds’s picture

Status: Needs review » Needs work

yes this will need a reroll with that batch api commit.

alex_b’s picture

Assigned: Scott Reynolds » alex_b

I'm going to take a shot at this now.

alex_b’s picture

Assigned: alex_b » Unassigned
Status: Needs work » Needs review
StatusFileSize
new8.12 KB

Ok, this is passing all tests now, will commit this soon.

- I used slightly different names for the import batch classes for file and http fetcher (FeedsHTTPBatch and FeedsFileBatch).
- Moved FeedHTTPBatch into FeedsHTTPFetcher and FeedsFileBatch into FeedsFileFetcher.

alex_b’s picture

Title: Break FeedsImportBatch into two classes » Break FeedsImportBatch into separate classes
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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