From 8f278023327cb29efb992a46d7ab3f218486d4f9 Mon Sep 17 00:00:00 2001 From: twistor <twistor@473738.no-reply.drupal.org> Date: Tue, 30 Jun 2015 12:54:53 -0700 Subject: [PATCH] Issue #2514300 by twistor: Fatal error when I try to import feed items --- mappers/file.inc | 3 +-- plugins/FeedsParser.inc | 2 +- plugins/FeedsSimplePieParser.inc | 2 ++ tests/feeds_parser_syndication.test | 11 +++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mappers/file.inc b/mappers/file.inc index d46c3191..4f705463 100644 --- a/mappers/file.inc +++ b/mappers/file.inc @@ -112,8 +112,7 @@ function file_feeds_set_target(FeedsSource $source, $entity, $target, array $val if ($v) { try { $v->setAllowedExtensions($instance_info['settings']['file_extensions']); - $file = $v->getFile($destination); - $field[LANGUAGE_NONE][$delta] += (array) $file; + $field[LANGUAGE_NONE][$delta] += (array) $v->getFile($destination); // @todo: Figure out how to properly populate this field. $field[LANGUAGE_NONE][$delta]['display'] = 1; } diff --git a/plugins/FeedsParser.inc b/plugins/FeedsParser.inc index 8b430c05..81545d75 100644 --- a/plugins/FeedsParser.inc +++ b/plugins/FeedsParser.inc @@ -435,7 +435,7 @@ class FeedsEnclosure extends FeedsElement { $file = new stdClass(); $file->uid = 0; $file->uri = $this->getSanitizedUri(); - $file->filemime = $this->mime_type; + $file->filemime = $this->getMIMEType(); $file->filename = $this->getSafeFilename(); if (drupal_dirname($file->uri) !== $destination) { diff --git a/plugins/FeedsSimplePieParser.inc b/plugins/FeedsSimplePieParser.inc index f87d9130..495b2a1a 100644 --- a/plugins/FeedsSimplePieParser.inc +++ b/plugins/FeedsSimplePieParser.inc @@ -52,6 +52,7 @@ class FeedsSimplePieEnclosure extends FeedsEnclosure { public function getMIMEType() { return $this->simplepie_enclosure->get_real_type(); } + } /** @@ -232,4 +233,5 @@ class FeedsSimplePieParser extends FeedsParser { $words = array_slice($words, 0, 3); return implode(' ', $words); } + } diff --git a/tests/feeds_parser_syndication.test b/tests/feeds_parser_syndication.test index 1d45ad9b..a62759f8 100644 --- a/tests/feeds_parser_syndication.test +++ b/tests/feeds_parser_syndication.test @@ -9,6 +9,7 @@ * Test single feeds. */ class FeedsSyndicationParserTestCase extends FeedsWebTestCase { + public static function getInfo() { return array( 'name' => 'Syndication parsers', @@ -39,6 +40,15 @@ class FeedsSyndicationParserTestCase extends FeedsWebTestCase { $this->assertText('Created ' . $assertions['item_count'] . ' nodes'); } } + + feeds_include_simplepie(); + variable_set('feeds_never_use_curl', TRUE); + + $link = $GLOBALS['base_url'] . '/testing/feeds/flickr.xml'; + $enclosure = new FeedsSimplePieEnclosure(new SimplePie_Enclosure($link)); + + $enclosure->setAllowedExtensions('xml'); + $this->assertEqual(1, $enclosure->getFile('public://')->fid); } /** @@ -55,4 +65,5 @@ class FeedsSyndicationParserTestCase extends FeedsWebTestCase { ), ); } + } -- GitLab