diff --git a/CHANGELOG.txt b/CHANGELOG.txt index bd7343a9c028327d871e4cb74f2d6ac9adb77ebf..4df33105fe1da941435e6a57f8d46463c9fc54c6 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 67f364a4331b19fb598646c4a7d083553957910c..ac62b50486e6caf0d15a5c3bd0cfec8944f05611 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 8f7b3dec88bc3aea8e7e690b08b5bd09f70950a9..81ad94f1714c261a1b6f2c6ef76e0eaad801dae7 100644 --- a/includes/FeedsSource.inc +++ b/includes/FeedsSource.inc @@ -110,6 +110,21 @@ class FeedsSource extends FeedsConfigurable { $this->load(); } + /** + * 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. *