Index: feeds.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/feeds.install,v retrieving revision 1.13.2.1 diff -r1.13.2.1 feeds.install 132a133,144 > 'touched' => array( > 'type' => 'int', > 'not null' => TRUE, > 'default' => 0, > 'description' => t('Mark when a feed item has last been touched, even if not updated.'), > ), > 'orphaned' => array( > 'type' => 'int', > 'not null' => TRUE, > 'default' => 0, > 'description' => t('Mark a feed item as orphaned, ready to be deleted or otherwise dealt with.'), > ), 569a582,607 > > /** > * Add touched and orphaned columns to feeds_node_item. > */ > function feeds_update_60014() { > $ret = array(); > > $touched = array( > 'type' => 'int', > 'not null' => TRUE, > 'default' => 0, > 'description' => t('Mark when a feed item has last been touched, even if not updated.'), > ); > > $orphaned = array( > 'type' => 'int', > 'not null' => TRUE, > 'default' => 0, > 'description' => t('Mark a feed item as orphaned, ready to be deleted or otherwise dealt with.'), > ); > > db_add_field($ret, 'feeds_node_item', 'touched', $touched); > db_add_field($ret, 'feeds_node_item', 'orphaned', $orphaned); > > return $ret; > } \ No newline at end of file Index: includes/FeedsBatch.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/includes/FeedsBatch.inc,v retrieving revision 1.15.2.1 diff -r1.15.2.1 FeedsBatch.inc 152a153,155 > public $unpublished; > public $deleted; > public $started; 168a172 > $this->started = time(); Index: includes/FeedsSource.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/includes/FeedsSource.inc,v retrieving revision 1.21.2.1 diff -r1.21.2.1 FeedsSource.inc 196a197,216 > public function clearOrphans() { > try { > if (!$this->batch || !($this->batch instanceof FeedsClearBatch)) { > $this->batch = new FeedsClearBatch(); > } > $this->importer->processor->clearOrphans($this->batch, $this); > $result = $this->batch->getProgress(); > if ($result == FEEDS_BATCH_COMPLETE) { > unset($this->batch); > } > } > catch (Exception $e) { > unset($this->batch); > $this->save(); > throw $e; > } > $this->save(); > return $result; > } > Index: plugins/FeedsNodeProcessor.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/plugins/FeedsNodeProcessor.inc,v retrieving revision 1.51.2.2 diff -r1.51.2.2 FeedsNodeProcessor.inc 17a18,23 > define('FEEDS_SYNC_REMOVED_IGNORE', 0); > define('FEEDS_SYNC_REMOVED_UNPUBLISH', 1); > define('FEEDS_SYNC_REMOVED_DELETE', 3); > > define('FEEDS_NODE_ORPHANED', 1); > 40a47,48 > // To be able to take action on items that have been removed, just indicate that this was still in the feed. > db_query("UPDATE {feeds_node_item} SET touched = %d WHERE nid = %d", FEEDS_REQUEST_TIME, $nid); 71a80 > $modified = FALSE; 73a83 > $modified = TRUE; 75c85 < elseif ($batch->updated) { --- > if ($batch->updated) { 76a87 > $modified = TRUE; 78,79c89,90 < else { < drupal_set_message(t('There is no new content.')); --- > if (!$modified) { > drupal_set_message(t('There have been no content changes.')); 80a92 > 81a94,98 > > // Handle nodes whose corresponding feed items have been removed. > if ($this->config['sync'] != FEEDS_SYNC_REMOVED_IGNORE) { > $this->flagOrphans($batch, $source); > } 113a131,174 > * Flag nodes that don't have a corresponding feed item in the feed anymore. > */ > public function flagOrphans($batch, $source) { > db_query("UPDATE {feeds_node_item} SET orphaned = 1 WHERE id = %d AND touched < %d", $source->id, $batch->started); > > if ($this->config['sync'] == FEEDS_SYNC_REMOVED_UNPUBLISH) { > // TODO: We'll see what we might do here later. > } > elseif ($this->config['sync'] == FEEDS_SYNC_REMOVED_DELETE) { > // TODO: This is almost certainly the wrong way...some input needed. > feeds_batch_set(t('Deleting'), 'clearOrphans', $source->id, $source->feed_nid); > } > } > > /** > * Implementation of FeedsProcessor::clearOrphans(). > */ > public function clearOrphans(FeedsBatch $batch, FeedsSource $source) { > if (!$batch->getTotal(FEEDS_CLEARING)) { > $total = db_result(db_query("SELECT COUNT(nid) FROM {feeds_node_item} WHERE id = '%s' AND feed_nid = %d AND orphaned = %d", $source->id, $source->feed_nid, FEEDS_NODE_ORPHANED)); > $batch->setTotal(FEEDS_CLEARING, $total); > } > $result = db_query_range("SELECT nid FROM {feeds_node_item} WHERE id = '%s' AND feed_nid = %d AND orphaned = %d", $source->id, $source->feed_nid, FEEDS_NODE_ORPHANED, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE)); > while ($node = db_fetch_object($result)) { > _feeds_node_delete($node->nid); > $batch->deleted++; > } > if (db_result(db_query_range("SELECT nid FROM {feeds_node_item} WHERE id = '%s' AND feed_nid = %d AND orphaned = %d", $source->id, $source->feed_nid, FEEDS_NODE_ORPHANED, 0, 1))) { > $batch->setProgress(FEEDS_CLEARING, $batch->deleted); > return; > } > > // Set message. > //drupal_get_messages('status', FALSE); > if ($batch->deleted) { > drupal_set_message(format_plural($batch->deleted, 'Deleted @number node.', 'Deleted @number nodes.', array('@number' => $batch->deleted))); > } > else { > drupal_set_message(t('There are no orphaned nodes to be deleted.')); > } > $batch->setProgress(FEEDS_CLEARING, FEEDS_BATCH_COMPLETE); > } > > /** 152a214 > 'sync' => FEEDS_SYNC_REMOVED_IGNORE, 207a270,280 > $form['sync'] = array( > '#type' => 'radios', > '#title' => t('Keep nodes and feed items in sync'), > '#description' => t('Select how nodes corresponding to removed feed items should be handled. This applies if you want to only display nodes that map to items currently in the feed.'), > '#options' => array( > FEEDS_SYNC_REMOVED_IGNORE => 'Do nothing', > FEEDS_SYNC_REMOVED_UNPUBLISH => 'Unpublish the node', > FEEDS_SYNC_REMOVED_DELETE => 'Delete the node', > ), > '#default_value' => $this->config['sync'], > ); 353a427 > $node->status = 1; 360a435 > $node->feeds_node_item->touched = FEEDS_REQUEST_TIME;