diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index 24ea707..6545135 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -118,10 +118,10 @@ function template_preprocess_search_result(&$variables) { if (!empty($result['module'])) { $info['module'] = check_plain($result['module']); } - if (!empty($result['user'])) { + if (!empty($result['user']) && !empty($result['node']) && variable_get('node_submitted_' . $result['node']->type, TRUE)) { $info['user'] = $result['user']; } - if (!empty($result['date'])) { + if (!empty($result['date']) && !empty($result['node']) && variable_get('node_submitted_' . $result['node']->type, TRUE)) { $info['date'] = format_date($result['date'], 'short'); } if (isset($result['extra']) && is_array($result['extra'])) { diff --git a/core/modules/search/search.test b/core/modules/search/search.test index f121abd..d106220 100644 --- a/core/modules/search/search.test +++ b/core/modules/search/search.test @@ -353,6 +353,19 @@ class SearchAdvancedSearchForm extends DrupalWebTestCase { $this->drupalPost('search/node', array_merge($edit, array('type[article]' => 'article')), t('Advanced search')); $this->assertText('bike shed', t('Article node is not found with POST query and type:article.')); + + // Check that with post settings turned on the post information is displayed. + variable_set('node_submitted_' . $this->node->type, TRUE); + $this->drupalGet('search/node/' . $this->node->title); + $user = user_load($this->node->uid); + $this->assertText($user->name, 'Basic page node displays author name when post settings are on.'); + $this->assertText(format_date($this->node->changed, 'short'), 'Basic page node displays post date when post settings are on.'); + + // Check that with post settings turned off the post information is not displayed. + variable_set('node_submitted_' . $this->node->type, FALSE); + $this->drupalGet('search/node/' . $this->node->title); + $this->assertNoText($user->name, 'Basic page node does not display author name when post settings are off.'); + $this->assertNoText(format_date($this->node->changed, 'short'), 'Basic page node does not display post date when post settings are off.'); } }