Skip to content
Snippets Groups Projects
Commit 6f4105c1 authored by Alex Barth's avatar Alex Barth
Browse files

#853194 andrewlevine, alex_b: Mapping: don't reset all targets.

parent 442a6990
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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.'),
......
......@@ -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) {
......
......@@ -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);
......
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