summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--feeds.module5
-rw-r--r--includes/FeedsSource.inc15
3 files changed, 17 insertions, 4 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index bd7343a..4df3310 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -3,6 +3,7 @@
Feeds 6.x 1.X XXXX
------------------
+- #850638 alex_b: Introduce FeedsSource::preview().
- #850298 alex_b: ParserCSV: Support batching (only affects library, full parser
level batch support to be added later with #744660).
- Minor cleanup of admin UI language and CSS.
diff --git a/feeds.module b/feeds.module
index 67f364a..ac62b50 100644
--- a/feeds.module
+++ b/feeds.module
@@ -271,10 +271,7 @@ function feeds_nodeapi(&$node, $op, $form) {
if (trim($node->title) == '') {
try {
$source->addConfig($node_feeds);
- // @todo Too many indirections. Clean up.
- $batch = $source->importer->fetcher->fetch($source);
- $source->importer->parser->parse($batch, $source);
- if (!$last_title = $batch->getTitle()) {
+ if (!$last_title = $source->preview()->getTitle()) {
throw new Exception();
}
}
diff --git a/includes/FeedsSource.inc b/includes/FeedsSource.inc
index 8f7b3de..81ad94f 100644
--- a/includes/FeedsSource.inc
+++ b/includes/FeedsSource.inc
@@ -111,6 +111,21 @@ class FeedsSource extends FeedsConfigurable {
}
/**
+ * Preview = fetch and parse a feed.
+ *
+ * @return
+ * FeedsImportBatch object, fetched and parsed.
+ *
+ * @throws
+ * Throws Exception if an error occurs when fetching or parsing.
+ */
+ public function preview() {
+ $batch = $this->importer->fetcher->fetch($this);
+ $this->importer->parser->parse($batch, $this);
+ return $batch;
+ }
+
+ /**
* Import a feed: execute, fetching, parsing and processing stage.
*
* Lock a source before importing by using FeedsSource::lock(), after