? .cvsignore ? feeds-661314.patch ? feeds-661314_use_expiry.patch ? feeds_ui/tests/.cvsignore ? tests/feeds/.cvsignore 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.'), > ), 569a582,607 > > /** > * Add touched and orphaned columns to feeds_node_item. > */ > function feeds_update_6014() { > $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.'), > ); > > 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 22a23 > $this->started = FEEDS_REQUEST_TIME; Index: includes/FeedsImporter.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/includes/FeedsImporter.inc,v retrieving revision 1.23.2.1 diff -r1.23.2.1 FeedsImporter.inc 91c91 < if (FEEDS_EXPIRE_NEVER != $this->processor->expiryTime()) { --- > if (FEEDS_EXPIRE_NEVER != $this->processor->expiryTime() || $this->processor->config['delete_orphans']) { 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,19 > define('FEEDS_NODE_ORPHANED', 1); > 38d39 < // Only proceed if item has actually changed. 40,41c41,46 < if (!empty($nid) && $hash == $this->getHash($nid)) { < continue; --- > if (!empty($nid)) { > // 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); > > // Only proceed if item has actually changed. > if ($hash == $this->getHash($nid)) continue; 71a77 > $modified = FALSE; 73a80 > $modified = TRUE; 75c82 < elseif ($batch->updated) { --- > if ($batch->updated) { 76a84 > $modified = TRUE; 78,79c86,87 < else { < drupal_set_message(t('There is no new content.')); --- > if (!$modified) { > drupal_set_message(t('There have been no content changes.')); 80a89 > 81a91,95 > > // Handle nodes whose corresponding feed items have been removed. > if ($this->config['delete_orphans']) { > $this->flagOrphans($batch, $source); > } 113a128,137 > * 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 = %d WHERE id = %d", 0, $source->id); > > db_query("UPDATE {feeds_node_item} SET orphaned = %d WHERE id = %d AND touched < %d", FEEDS_NODE_ORPHANED, $source->id, $batch->started); > drupal_set_message(t('Flagged %num orphaned nodes for deletion.', array('%num' => db_affected_rows()))); > } > > /** 116a141,143 > $or = array(); > $args = array(); > 120,121c147,149 < if ($time == FEEDS_EXPIRE_NEVER) { < return; --- > if ($time != FEEDS_EXPIRE_NEVER) { > $or[] = 'n.created < %d'; > $args[] = FEEDS_REQUEST_TIME - $time; 123c151,160 < $result = db_query_range("SELECT n.nid FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = '%s' AND n.created < %d", $this->id, FEEDS_REQUEST_TIME - $time, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE)); --- > > if ($this->config['delete_orphans']) { > $or[] = 'orphaned = %d'; > $args[] = FEEDS_NODE_ORPHANED; > } > > $or = implode(' OR ', $or); > $args = implode(', ', $args); > > $result = db_query_range("SELECT n.nid FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = '%s' AND ($or)", $this->id, $args, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE)); 127c164 < if (db_result(db_query_range("SELECT n.nid FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = '%s' AND n.created < %d", $this->id, FEEDS_REQUEST_TIME - $time, 0, 1))) { --- > if (db_result(db_query_range("SELECT n.nid FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = '%s' AND ($or)", $this->id, $args, 0, 1))) { 152a190 > 'delete_orphans' => 0, 207a246,251 > $form['delete_orphans'] = array( > '#type' => 'checkbox', > '#title' => t('Delete nodes for missing items'), > '#description' => t('Delete existing nodes if the corresponding item no longer appears in the feed.'), > '#default_value' => $this->config['delete_orphans'], > ); 224c268 < * Reschedule if expiry time changes. --- > * Reschedule if expiry time changes or deleting orphans gets enabled. 227c271 < if ($this->config['expire'] != $values['expire']) { --- > if ($this->config['expire'] != $values['expire'] || $values['delete_orphans']) { 360a405 > $node->feeds_node_item->touched = FEEDS_REQUEST_TIME;