diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f787011bfe8d7f3395d519ccfd54954ca13b8563..301c425d8719e34851a272ff9db658424a4ae75c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ Feeds 6.x 1.X XXXX ------------------ +- #853194 andrewlevine, alex_b: Mapping: don't reset all targets. - #853144 alex_b: Consistent use of "replace" vs "update". - #850998 alex_b: Clean up file upload form. Note: If you supply file paths directly in the textfield rather than uploading them through the UI, you will diff --git a/plugins/FeedsNodeProcessor.inc b/plugins/FeedsNodeProcessor.inc index b89601542b958fe1a94f45ef494970b017c86144..8d7dfc24d2a4f3add90b498822df8ccc5bfdd023 100644 --- a/plugins/FeedsNodeProcessor.inc +++ b/plugins/FeedsNodeProcessor.inc @@ -259,6 +259,10 @@ class FeedsNodeProcessor extends FeedsProcessor { ); } $targets += array( + 'uid' => array( + 'name' => t('User ID'), + 'description' => t('The Drupal user ID of the node author.'), + ), 'status' => array( 'name' => t('Published status'), 'description' => t('Whether a node is published or not. 1 stands for published, 0 for not published.'), diff --git a/plugins/FeedsProcessor.inc b/plugins/FeedsProcessor.inc index be1e0c3b48aa35ce7b94341ec4313fd882604e55..4f049d7707cb7566821cba906ea7980b119ed653 100644 --- a/plugins/FeedsProcessor.inc +++ b/plugins/FeedsProcessor.inc @@ -108,12 +108,12 @@ abstract class FeedsProcessor extends FeedsPlugin { $target_item = (object)$target_item; $convert_to_array = TRUE; } - foreach ($targets[$this->id] as $target_name => $target) { - if (isset($target['real_target']) && isset($target_item->$target['real_target'])) { - unset($target_item->$target['real_target']); + foreach ($this->config['mappings'] as $mapping) { + if (isset($targets[$mapping['target']]['real_target'])) { + unset($target_item->{$targets[$mapping['target']]['real_target']}); } - else if (isset($target_item->$target_name)) { - unset($target_item->$target_name); + elseif (isset($target_item->{$mapping['target']})) { + unset($target_item->{$mapping['target']}); } } if ($convert_to_array) { diff --git a/tests/feeds.test b/tests/feeds.test index 3adae982c3eb83e2a682e89ba520eac0d9ff7d62..7ebe943f0162558c65f448904150a9267b6e39aa 100644 --- a/tests/feeds.test +++ b/tests/feeds.test @@ -33,7 +33,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { $this->drupalLogin( $this->drupalCreateUser( array( - 'administer feeds', 'administer nodes', + 'administer feeds', 'administer nodes', 'administer content types', ) ) ); @@ -133,7 +133,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { $this->assertText('The first major change is switching'); // Assert DB status. - $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}")); + $count = db_result(db_query("SELECT COUNT(*) FROM {node} n INNER JOIN {feeds_node_item} fn ON n.nid = fn.nid")); $this->assertEqual($count, 10, 'Accurate number of items in database.'); // Assert default input format on first imported feed node. @@ -145,10 +145,29 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { $this->assertText('There is no new content.'); // Assert DB status, there still shouldn't be more than 10 items. - $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}")); + $count = db_result(db_query("SELECT COUNT(*) FROM {node} n INNER JOIN {feeds_node_item} fn ON n.nid = fn.nid")); $this->assertEqual($count, 10, 'Accurate number of items in database.'); + // All of the above tests should have produced published nodes, set default + // to unpublished, import again. + $count = db_result(db_query("SELECT COUNT(*) FROM {node} n INNER JOIN {feeds_node_item} fn ON n.nid = fn.nid WHERE n.status = 1")); + $this->assertEqual($count, 10, 'All items are published.'); + $edit = array( + 'node_options[status]' => FALSE, + ); + $this->drupalPost('admin/content/node-type/story', $edit, t('Save content type')); + $this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete'); + $this->drupalPost('node/'. $nid .'/import', array(), 'Import'); + $count = db_result(db_query("SELECT COUNT(*) FROM {node} n INNER JOIN {feeds_node_item} fn ON n.nid = fn.nid WHERE n.status = 0")); + $this->assertEqual($count, 10, 'No items are published.'); + $edit = array( + 'node_options[status]' => TRUE, + ); + $this->drupalPost('admin/content/node-type/story', $edit, t('Save content type')); + $this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete'); + // Enable replace existing and import updated feed file. + $this->drupalPost('node/'. $nid .'/import', array(), 'Import'); $this->setSettings('syndication', 'FeedsNodeProcessor', array('update_existing' => 1)); $feed_url = $GLOBALS['base_url'] .'/'. drupal_get_path('module', 'feeds') .'/tests/feeds/developmentseed_changes.rss2'; $this->editFeedNode($nid, $feed_url);