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

#853144 alex_b: Consistent use of replace vs update.

parent 6c8ed1cd
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
Feeds 6.x 1.X XXXX
------------------
- #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
have to adjust your importer's File Fetcher settings.
......
......@@ -254,7 +254,7 @@ class FeedsDataProcessor extends FeedsProcessor {
*/
public function configDefaults() {
return array(
'update_existing' => 0,
'update_existing' => FEEDS_SKIP_EXISTING,
'expire' => FEEDS_EXPIRE_NEVER, // Don't expire items by default.
'mappings' => array(),
);
......@@ -264,12 +264,6 @@ class FeedsDataProcessor extends FeedsProcessor {
* Override parent::configForm().
*/
public function configForm(&$form_state) {
$form['update_existing'] = array(
'#type' => 'checkbox',
'#title' => t('Update existing items'),
'#description' => t('Check if existing items should be updated from the feed.'),
'#default_value' => $this->config['update_existing'],
);
$period = drupal_map_assoc(array(FEEDS_EXPIRE_NEVER, 3600, 10800, 21600, 43200, 86400, 259200, 604800, 604800 * 4, 604800 * 12, 604800 * 24, 31536000), 'feeds_format_expire');
$form['expire'] = array(
'#type' => 'select',
......@@ -278,6 +272,12 @@ class FeedsDataProcessor extends FeedsProcessor {
'#description' => t('Select after how much time data records should be deleted. The timestamp target value will be used for determining the item\'s age, see Mapping settings.'),
'#default_value' => $this->config['expire'],
);
$form['update_existing'] = array(
'#type' => 'checkbox',
'#title' => t('Replace existing records'),
'#description' => t('If an existing record is found for an imported record, replace it. Existing records will be determined using mappings that are a "unique target".'),
'#default_value' => $this->config['update_existing'],
);
return $form;
}
......
......@@ -137,10 +137,11 @@ class FeedsFeedNodeProcessor extends FeedsProcessor {
'#options' => $types,
'#default_value' => $this->config['content_type'],
);
// @todo Implement real updating.
$form['update_existing'] = array(
'#type' => 'checkbox',
'#title' => t('Update existing items'),
'#description' => t('Check if existing items should be updated from the feed.'),
'#title' => t('Replace existing feed nodes'),
'#description' => t('If an existing node is found for an imported node, replace it. Existing nodes will be determined using mappings that are a "unique target".'),
'#default_value' => $this->config['update_existing'],
);
return $form;
......
......@@ -9,7 +9,8 @@
// Create or delete FEEDS_NODE_BATCH_SIZE at a time.
define('FEEDS_NODE_BATCH_SIZE', 50);
// Updating mode for existing nodes.
// Deprecated. Use FEEDS_SKIPE_EXISTING, FEEDS_REPLACE_EXISTNG,
// FEEDS_UPDATE_EXISTING instead.
define('FEEDS_NODE_SKIP_EXISTING', 0);
define('FEEDS_NODE_REPLACE_EXISTING', 1);
define('FEEDS_NODE_UPDATE_EXISTING', 2);
......@@ -30,7 +31,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
while ($item = $batch->shiftItem()) {
// Create/update if item does not exist or update existing is enabled.
if (!($nid = $this->existingItemId($item, $source)) || ($this->config['update_existing'] != FEEDS_NODE_SKIP_EXISTING)) {
if (!($nid = $this->existingItemId($item, $source)) || ($this->config['update_existing'] != FEEDS_SKIP_EXISTING)) {
$node = $this->buildNode($nid, $source->feed_nid);
// Only proceed if item has actually changed.
......@@ -148,7 +149,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
return array(
'content_type' => $type,
'input_format' => FILTER_FORMAT_DEFAULT,
'update_existing' => FEEDS_NODE_SKIP_EXISTING,
'update_existing' => FEEDS_SKIP_EXISTING,
'expire' => FEEDS_EXPIRE_NEVER,
'mappings' => array(),
'author' => 0,
......@@ -199,11 +200,11 @@ class FeedsNodeProcessor extends FeedsProcessor {
$form['update_existing'] = array(
'#type' => 'radios',
'#title' => t('Update existing items'),
'#description' => t('Select how existing nodes should be updated.'),
'#description' => t('Select how existing nodes should be updated. Existing nodes will be determined using mappings that are a "unique target".'),
'#options' => array(
FEEDS_NODE_SKIP_EXISTING => 'Do not update existing nodes',
FEEDS_NODE_REPLACE_EXISTING => 'Replace existing nodes',
FEEDS_NODE_UPDATE_EXISTING => 'Update existing nodes (slower than replacing them)',
FEEDS_SKIP_EXISTING => 'Do not update existing nodes',
FEEDS_REPLACE_EXISTING => 'Replace existing nodes',
FEEDS_UPDATE_EXISTING => 'Update existing nodes (slower than replacing them)',
),
'#default_value' => $this->config['update_existing'],
);
......@@ -319,7 +320,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
$populate = TRUE;
}
else {
if ($this->config['update_existing'] == FEEDS_NODE_UPDATE_EXISTING) {
if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
$node = node_load($nid, NULL, TRUE);
}
else {
......
<?php
// $Id$
// Update mode for existing items.
define('FEEDS_SKIP_EXISTING', 0);
define('FEEDS_REPLACE_EXISTING', 1);
define('FEEDS_UPDATE_EXISTING', 2);
/**
* Abstract class, defines interface for processors.
*/
......
......@@ -145,10 +145,11 @@ class FeedsTermProcessor extends FeedsProcessor {
'#options' => $options,
'#default_value' => $this->config['vocabulary'],
);
// @todo Implement true updating.
$form['update_existing'] = array(
'#type' => 'checkbox',
'#title' => t('Update existing items'),
'#description' => t('Check if existing terms should be updated from the feed.'),
'#title' => t('Replace existing terms'),
'#description' => t('If an existing term is found for an imported term, replace it. Existing terms will be determined using mappings that are a "unique target".'),
'#default_value' => $this->config['update_existing'],
);
return $form;
......
......@@ -145,11 +145,11 @@ class FeedsUserProcessor extends FeedsProcessor {
'#options' => $roles,
);
}
// @todo Implement true updating.
$form['update_existing'] = array(
'#type' => 'checkbox',
'#title' => t('Update existing users'),
'#description' => t('Check if existing users should be updated from imported data.'),
'#title' => t('Replace existing users'),
'#description' => t('If an existing user is found for an imported user, replace it. Existing users will be determined using mappings that are a "unique target".'),
'#default_value' => $this->config['update_existing'],
);
return $form;
......
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