Skip to content
Snippets Groups Projects
Commit 6b5a7ea4 authored by megachriz's avatar megachriz Committed by MegaChriz
Browse files

Issue #2719151 by MegaChriz: Fixed don't retrieve title from feed if feed node...

Issue #2719151 by MegaChriz: Fixed don't retrieve title from feed if feed node does not use the node title field.
parent 144a78b9
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
......@@ -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.');
}
}
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