Skip to content
Snippets Groups Projects
Commit 5959bcb0 authored by Alex Barth's avatar Alex Barth
Browse files

#867892 alex_b: PubSubHubbub - slow down import frequency of feeds that are subscribed to hub.

parent f544c313
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
Feeds 6.x xxxxxxxxxxxxxxxxxxxxxx Feeds 6.x xxxxxxxxxxxxxxxxxxxxxx
-------------------------------- --------------------------------
- #867892 alex_b: PubSubHubbub - slow down import frequency of feeds that are
subscribed to hub.
- #908964 alex_b: Break out scheduler. Note: Features depends on Job Scheduler - #908964 alex_b: Break out scheduler. Note: Features depends on Job Scheduler
module now: http://drupal.org/project/job_scheduler module now: http://drupal.org/project/job_scheduler
- #663860 funkmasterjones, infojunkie, alex_b et. al.: hook_feeds_after_parse(). - #663860 funkmasterjones, infojunkie, alex_b et. al.: hook_feeds_after_parse().
......
...@@ -198,12 +198,18 @@ class FeedsSource extends FeedsConfigurable { ...@@ -198,12 +198,18 @@ class FeedsSource extends FeedsConfigurable {
* Schedule this source. * Schedule this source.
*/ */
public function schedule() { public function schedule() {
// Check whether any fetcher is overriding the import period.
$period = $this->importer->config['import_period'];
$fetcher_period = $this->importer->fetcher->importPeriod($this);
if (is_numeric($fetcher_period)) {
$period = $fetcher_period;
}
$job = array( $job = array(
'callback' => 'feeds_source_import', 'callback' => 'feeds_source_import',
'type' => $this->id, 'type' => $this->id,
'id' => $this->feed_nid, 'id' => $this->feed_nid,
// Schedule as soon as possible if a batch is active. // Schedule as soon as possible if a batch is active.
'period' => $this->batch ? 0 : $this->importer->config['import_period'], 'period' => $this->batch ? 0 : $period,
'periodic' => TRUE, 'periodic' => TRUE,
); );
if ($job['period'] != FEEDS_SCHEDULE_NEVER) { if ($job['period'] != FEEDS_SCHEDULE_NEVER) {
......
...@@ -94,4 +94,17 @@ abstract class FeedsFetcher extends FeedsPlugin { ...@@ -94,4 +94,17 @@ abstract class FeedsFetcher extends FeedsPlugin {
* Source information for unsubscribing. * Source information for unsubscribing.
*/ */
public function unsubscribe(FeedsSource $source) {} public function unsubscribe(FeedsSource $source) {}
/**
* Override import period settings. This can be used to force a certain import
* interval.
*
* @param $source
* A FeedsSource object.
*
* @return
* A time span in seconds if periodic import should be overridden for given
* $source, NULL otherwise.
*/
public function importPeriod(FeedsSource $source) {}
} }
...@@ -192,6 +192,15 @@ class FeedsHTTPFetcher extends FeedsFetcher { ...@@ -192,6 +192,15 @@ class FeedsHTTPFetcher extends FeedsFetcher {
$this->subscriber($source->feed_nid)->unsubscribe($source_config['source'], url($this->path($source->feed_nid), array('absolute' => TRUE))); $this->subscriber($source->feed_nid)->unsubscribe($source_config['source'], url($this->path($source->feed_nid), array('absolute' => TRUE)));
} }
/**
* Implement FeedsFetcher::importPeriod().
*/
public function importPeriod(FeedsSource $source) {
if ($this->subscriber($source->feed_nid)->subscribed()) {
return 259200; // Delay for three days if there is a successful subscription.
}
}
/** /**
* Convenience method for instantiating a subscriber object. * Convenience method for instantiating a subscriber object.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment