Skip to content
Snippets Groups Projects
Commit cb04a06b authored by mikran's avatar mikran Committed by Chris Leppanen
Browse files

Issue #2339383 by mikran, MegaChriz, joelpittet: Items missing from feeds do...

Issue #2339383 by mikran, MegaChriz, joelpittet: Items missing from feeds do not affect item hash even when action is taken based on that
parent 83d7c2ec
No related branches found
No related tags found
No related merge requests found
...@@ -398,9 +398,10 @@ class FeedsNodeProcessor extends FeedsProcessor { ...@@ -398,9 +398,10 @@ class FeedsNodeProcessor extends FeedsProcessor {
if ($total) { if ($total) {
$nodes = node_load_multiple($state->removeList); $nodes = node_load_multiple($state->removeList);
foreach ($nodes as &$node) { foreach ($nodes as &$node) {
if ($node->status == 0) { $this->loadItemInfo($node);
continue; // Update the hash value of the feed item to ensure that the item gets
} // updated in case it reappears in the feed.
$node->feeds_item->hash = $this->config['update_non_existent'];
node_unpublish_action($node); node_unpublish_action($node);
node_save($node); node_save($node);
$state->unpublished++; $state->unpublished++;
......
...@@ -375,6 +375,8 @@ abstract class FeedsProcessor extends FeedsPlugin { ...@@ -375,6 +375,8 @@ abstract class FeedsProcessor extends FeedsPlugin {
$select->condition('fi.id', $this->id); $select->condition('fi.id', $this->id);
$select->condition('fi.feed_nid', $source->feed_nid); $select->condition('fi.feed_nid', $source->feed_nid);
// No need to remove item again if same method of removal was already used.
$select->condition('fi.hash', $this->config['update_non_existent'], '<>');
$entities = $select->execute(); $entities = $select->execute();
// If not found on process, existing entities will be deleted. // If not found on process, existing entities will be deleted.
foreach ($entities as $entity) { foreach ($entities as $entity) {
......
...@@ -294,12 +294,27 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { ...@@ -294,12 +294,27 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$this->assertFeedItemCount(10); $this->assertFeedItemCount(10);
// Enable unpublish missing nodes and import updated feed file. // Enable unpublish missing nodes and import updated feed file.
$this->setSettings('syndication_standalone', 'FeedsNodeProcessor', array('update_non_existent' => 'unpublish')); $this->setSettings('syndication_standalone', 'FeedsNodeProcessor', array('update_non_existent' => FEEDS_UNPUBLISH_NON_EXISTENT, 'update_existing' => FEEDS_REPLACE_EXISTING));
$missing_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed_missing.rss2'; $missing_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed_missing.rss2';
$this->importURL('syndication_standalone', $missing_url); $this->importURL('syndication_standalone', $missing_url);
$this->assertText('Unpublished 1 node'); $this->assertText('Unpublished 1 node');
$this->assertFeedItemCount(10); $this->assertFeedItemCount(10);
// Import again to ensure the message that one node is unpublished doesn't
// reappear (since the node was already unpublished during the previous
// import).
$this->drupalPost('import/syndication_standalone', array(), 'Import');
$this->assertText('There are no new nodes');
$this->assertFeedItemCount(10);
// Re-import the original feed to ensure the unpublished node is updated,
// even though the item is the same since the last time it was available in
// the feed. Fact is that the node was not available in the previous import
// and that should be seen as a change.
$this->importURL('syndication_standalone', $feed_url);
$this->assertText('Updated 1 node');
$this->assertFeedItemCount(10);
// Now delete all items. // Now delete all items.
$this->drupalPost('import/syndication_standalone/delete-items', array(), 'Delete'); $this->drupalPost('import/syndication_standalone/delete-items', array(), 'Delete');
$this->assertText('Deleted 10 nodes'); $this->assertText('Deleted 10 nodes');
......
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