diff --git a/feeds.module b/feeds.module index 061e0dd3aa7449a36d6eacce3d86d46096bc1642..7cded509c029a785a501af7a4c663491a3feecdf 100644 --- a/feeds.module +++ b/feeds.module @@ -609,7 +609,7 @@ function feeds_node_validate($node, $form, &$form_state) { // If the node title is empty and the title form element wasn't hidden, try to // retrieve the title from the feed. - if (trim($node->title) == '' && !$title_hidden) { + if (isset($node->title) && trim($node->title) == '' && !$title_hidden) { try { $source->addConfig($last_feeds); if (!$last_title = $source->preview()->title) { diff --git a/tests/feeds_content_type.test b/tests/feeds_content_type.test index 9fe67bde2b1f2826c5f0bf7eb3afa6ebbe245ec3..4ee2b2aa68eb5dc4fe9b72c14c6909fa7eabef23 100644 --- a/tests/feeds_content_type.test +++ b/tests/feeds_content_type.test @@ -79,4 +79,32 @@ class FeedsContentTypeTest extends FeedsWebTestCase { $this->assertText('Title field is required.'); } + + /** + * Tests that the feed node gets no title if the content type does not use the + * node title field. + */ + public function testWithContentTypeWithoutTitle() { + // Set that the content type 'page' has no title. + db_update('node_type') + ->fields(array( + 'has_title' => 0, + )) + ->condition('type', 'page') + ->execute(); + + // Flush caches so this change is picked up. + drupal_flush_all_caches(); + + // And import a RSS feed with a title. + $edit = array( + 'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2', + ); + $this->drupalPost('node/add/page', $edit, 'Save'); + + // Assert that the feed node didn't got a title from the source. + $node = node_load(1); + $this->assertEqual('', $node->title, 'The feed node has no title.'); + } + }