Skip to content
Snippets Groups Projects
Commit 5549eea7 authored by Will White's avatar Will White
Browse files

bug report #740962 by alex_b, ocean_cybrarian: FileFetcher Attached to Feed...

bug report #740962 by alex_b, ocean_cybrarian: FileFetcher Attached to Feed Node, Upload Field Not Saving File Path.
parent fe86b16a
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,8 @@ Feeds 6.x 1.0 xxxxx xx, 2010-xx-xx ...@@ -31,6 +31,8 @@ Feeds 6.x 1.0 xxxxx xx, 2010-xx-xx
importer id. importer id.
- #718474 jerdavis: In FeedsNodeProcessor, check for duplicate items within - #718474 jerdavis: In FeedsNodeProcessor, check for duplicate items within
same importer id. same importer id.
- #740962 Fix FileFetcher Attached to Feed Node, Upload Field Not Saving File
Path.
Feeds 6.x 1.0 Alpha 12, 2010-02-23 Feeds 6.x 1.0 Alpha 12, 2010-02-23
---------------------------------- ----------------------------------
......
...@@ -238,9 +238,19 @@ function feeds_feeds_plugins() { ...@@ -238,9 +238,19 @@ function feeds_feeds_plugins() {
/** /**
* Implementation of hook_nodeapi(). * Implementation of hook_nodeapi().
*
* @todo For Drupal 7, revisit static cache based shuttling of values between
* 'validate' and 'update'/'insert'.
*/ */
function feeds_nodeapi(&$node, $op, $form) { function feeds_nodeapi(&$node, $op, $form) {
// $node looses any changes after 'validate' stage (see node_form_validate()).
// Keep a copy of title and feeds array between 'validate' and subsequent
// stages. This allows for automatically populating the title of the node form
// and modifying the $form['feeds'] array on node validation just like on the
// standalone form.
static $last_title; static $last_title;
static $node_feeds;
// Break out node processor related nodeapi functionality. // Break out node processor related nodeapi functionality.
_feeds_nodeapi_node_processor($node, $op); _feeds_nodeapi_node_processor($node, $op);
...@@ -253,16 +263,17 @@ function feeds_nodeapi(&$node, $op, $form) { ...@@ -253,16 +263,17 @@ function feeds_nodeapi(&$node, $op, $form) {
// this stage. // this stage.
$source = feeds_source($importer_id); $source = feeds_source($importer_id);
// Node module magically moved $form['feeds'] to $node->feeds :P
$node_feeds = $node->feeds;
$source->configFormValidate($node_feeds);
// If node title is empty, try to retrieve title from feed. // If node title is empty, try to retrieve title from feed.
if (trim($node->title) == '') { if (trim($node->title) == '') {
try { try {
$source->addConfig($node->feeds); $source->addConfig($node_feeds);
// @todo Too many indirections. Clean up. // @todo Too many indirections. Clean up.
$batch = $source->importer->fetcher->fetch($source); $batch = $source->importer->fetcher->fetch($source);
$source->importer->parser->parse($batch, $source); $source->importer->parser->parse($batch, $source);
// Keep the title in a static cache and populate $node->title on
// 'presave' as node module looses any changes to $node after
// 'validate'.
if (!$last_title = $batch->getTitle()) { if (!$last_title = $batch->getTitle()) {
throw new Exception(); throw new Exception();
} }
...@@ -272,10 +283,6 @@ function feeds_nodeapi(&$node, $op, $form) { ...@@ -272,10 +283,6 @@ function feeds_nodeapi(&$node, $op, $form) {
form_set_error('title', t('Could not retrieve title from feed.'), 'error'); form_set_error('title', t('Could not retrieve title from feed.'), 'error');
} }
} }
// Invoke source
// Node module magically moved $form['feeds'] to $node->feeds :P
$source->configFormValidate($node->feeds);
break; break;
case 'presave': case 'presave':
if (!empty($last_title)) { if (!empty($last_title)) {
...@@ -287,12 +294,12 @@ function feeds_nodeapi(&$node, $op, $form) { ...@@ -287,12 +294,12 @@ function feeds_nodeapi(&$node, $op, $form) {
case 'update': case 'update':
// Add configuration to feed source and save. // Add configuration to feed source and save.
$source = feeds_source($importer_id, $node->nid); $source = feeds_source($importer_id, $node->nid);
$source->addConfig($node->feeds); $source->addConfig($node_feeds);
$source->save(); $source->save();
// Refresh feed if import on create is selected and suppress_import is // Refresh feed if import on create is selected and suppress_import is
// not set. // not set.
if ($op == 'insert' && feeds_importer($importer_id)->config['import_on_create'] && !isset($node->feeds['suppress_import'])) { if ($op == 'insert' && feeds_importer($importer_id)->config['import_on_create'] && !isset($node_feeds['suppress_import'])) {
feeds_batch_set(t('Importing'), 'import', $importer_id, $node->nid); feeds_batch_set(t('Importing'), 'import', $importer_id, $node->nid);
} }
// Add import to scheduler. // Add import to scheduler.
...@@ -300,6 +307,7 @@ function feeds_nodeapi(&$node, $op, $form) { ...@@ -300,6 +307,7 @@ function feeds_nodeapi(&$node, $op, $form) {
// Add expiry to schedule, in case this is the first feed of this // Add expiry to schedule, in case this is the first feed of this
// configuration. // configuration.
feeds_scheduler()->add($importer_id, 'expire'); feeds_scheduler()->add($importer_id, 'expire');
unset($node_feeds);
break; break;
case 'delete': case 'delete':
// Remove feed from scheduler and delete source. // Remove feed from scheduler and delete source.
...@@ -348,6 +356,8 @@ function feeds_form_alter(&$form, $form_state, $form_id) { ...@@ -348,6 +356,8 @@ function feeds_form_alter(&$form, $form_state, $form_id) {
if ($importer_id = feeds_get_importer_id($form['type']['#value'])) { if ($importer_id = feeds_get_importer_id($form['type']['#value'])) {
// Set title to not required, try to retrieve it from feed. // Set title to not required, try to retrieve it from feed.
$form['title']['#required'] = FALSE; $form['title']['#required'] = FALSE;
// Enable uploads.
$form['#attributes']['enctype'] = 'multipart/form-data';
// Build form. // Build form.
$source = feeds_source($importer_id, empty($form['nid']['#value']) ? 0 : $form['nid']['#value']); $source = feeds_source($importer_id, empty($form['nid']['#value']) ? 0 : $form['nid']['#value']);
......
...@@ -20,7 +20,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { ...@@ -20,7 +20,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
public function getInfo() { public function getInfo() {
return array( return array(
'name' => t('RSS import to nodes'), 'name' => t('RSS import to nodes'),
'description' => t('Tests a feed configuration that is attached to a content type, uses common syndication parser and a node processor. Repeats the same test for a feed configuration that is not attached to a content type.'), 'description' => t('Tests a feed configuration that is attached to a content type, uses HTTP fetcher, common syndication parser and a node processor. Repeats the same test for an importer configuration that is not attached to a content type and for a configuration that is attached to a content type and uses the file fetcher.'),
'group' => t('Feeds'), 'group' => t('Feeds'),
); );
} }
...@@ -321,6 +321,19 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { ...@@ -321,6 +321,19 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
// Navigate to feed import form, access should be denied. // Navigate to feed import form, access should be denied.
$this->drupalGet('import/syndication_standalone'); $this->drupalGet('import/syndication_standalone');
$this->assertResponse(403); $this->assertResponse(403);
// Use File Fetcher.
$this->drupalLogin(
$this->drupalCreateUser(array('administer feeds', 'administer nodes'))
);
$this->setPlugin('syndication', 'FeedsFileFetcher');
// Create a feed node.
$edit = array(
'files[feeds]' => $this->absolutePath() .'/tests/feeds/drupalplanet.rss2',
);
$this->drupalPost('node/add/page', $edit, 'Save');
$this->assertText('has been created.');
$this->assertText('Created 25 Story 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