Skip to content
Snippets Groups Projects
Commit 870db3f9 authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Some crap snuck into that last commit.

parent 7c462d05
No related branches found
No related tags found
No related merge requests found
......@@ -43,13 +43,14 @@ function feeds_hook_info() {
function feeds_cron() {
if ($importers = feeds_reschedule()) {
foreach ($importers as $id) {
feeds_importer($id)->schedule();
$rows = db_query("SELECT feed_nid FROM {feeds_source} WHERE id = :id", array(':id' => $id));
foreach ($rows as $row) {
feeds_source($id, $row->feed_nid)->schedule();
}
}
feeds_reschedule(FALSE);
}
// Expire old log entries.
db_delete('feeds_log')
->condition('request_time', REQUEST_TIME - 604800, '<')
......@@ -189,37 +190,31 @@ function feeds_batch($method, $importer_id, $feed_nid = 0, &$context) {
}
}
/**
* Reschedules an importer's sources.
*
* The importers designated to be rescheduled wil have their sources
* rescheduled on the next cron run.
*
* @param string $importer_id
* (Optional) If an importer id, that importer will be added to the list
* for rescheduling. If NULL, the list of importers will be reset.
*
* @return array
* The list of importers that need to have their sources rescheduled.
*
* @see feeds_cron()
*/
function feeds_reschedule($importer_id = NULL) {
// Get a list of importers.
$reschedule = variable_get('feeds_reschedule', array());
// We are adding one to the list.
if ($importer_id) {
$reschedule[] = $importer_id;
$reschedule = array_unique($reschedule);
variable_set('feeds_reschedule', $reschedule);
/**
* Reschedule one or all importers.
*
* @param $importer_id
* If TRUE, all importers will be rescheduled, if FALSE, no importers will
* be rescheduled, if an importer id, only importer of that id will be
* rescheduled.
*
* @return
* TRUE if all importers need rescheduling. FALSE if no rescheduling is
* required. An array of importers that need rescheduling.
*/
function feeds_reschedule($importer_id = NULL) {
$reschedule = variable_get('feeds_reschedule', FALSE);
if ($importer_id === TRUE || $importer_id === FALSE) {
$reschedule = $importer_id;
}
else {
variable_del('feeds_reschedule');
elseif (is_string($importer_id) && $reschedule !== TRUE) {
$reschedule = is_array($reschedule) ? $reschedule : array();
$reschedule[$importer_id] = $importer_id;
}
variable_set('feeds_reschedule', $reschedule);
if ($reschedule === TRUE) {
return feeds_enabled_importers();
}
return $reschedule;
}
......
......@@ -95,7 +95,6 @@ class FeedsImporter extends FeedsConfigurable {
else {
JobScheduler::get('feeds_importer_expire')->remove($job);
}
debug($job);
}
/**
......@@ -127,20 +126,13 @@ class FeedsImporter extends FeedsConfigurable {
if ($config = db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => $this->id))->fetchField()) {
drupal_write_record('feeds_importer', $save, 'id');
// Only rebuild menu if content_type has changed. Don't worry about
// rebuilding menus when creating a new importer since it will default
// to the standalone page.
$config = unserialize($config);
if ($config['content_type'] != $save->config['content_type']) {
variable_set('menu_rebuild_needed', TRUE);
}
// Reschedule this importer's sources if the import period changed.
if ($config['import_period'] != $save->config['import_period']) {
feeds_reschedule($this->id);
}
}
else {
drupal_write_record('feeds_importer', $save);
......@@ -176,7 +168,6 @@ class FeedsImporter extends FeedsConfigurable {
);
if ($this->export_type & EXPORT_IN_CODE) {
feeds_reschedule($this->id);
$this->schedule();
}
else {
JobScheduler::get('feeds_importer_expire')->remove($job);
......@@ -319,6 +310,16 @@ class FeedsImporter extends FeedsConfigurable {
);
return $form;
}
/**
* Reschedule if import period changes.
*/
public function configFormSubmit(&$values) {
if ($this->config['import_period'] != $values['import_period']) {
feeds_reschedule($this->id);
}
parent::configFormSubmit($values);
}
}
/**
......
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