When searching, the results page shows publishing information (author, date/time) for all results, even when the content type is set to "Do not display post information". The publishing information is not displayed on the node page itself however, as expected.

Even when the author is set to Anonymous, the author and timestamp are still shown. I would have thought the publishing information on the search snippet would have mirrored that of the node page.

CommentFileSizeAuthor
#2 search_results_submitted.patch1.17 KBfuramag

Comments

furamag’s picture

Per my understanding there is bug in node_search_execute function in node.module.
Now we are using following code (line 1615):

  $results = array();
  foreach ($find as $item) {
    // Render the node.
    $node = node_load($item->sid);
    $build = node_view($node, 'search_result');
    unset($build['#theme']);
    $node->rendered = drupal_render($build);

    // Fetch comments for snippet.
    $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node);

    $extra = module_invoke_all('node_search_result', $node);

    $uri = entity_uri('node', $node);
    $results[] = array(
      'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE))),
      'type' => check_plain(node_type_get_name($node)),
      'title' => $node->title,
      'user' => theme('username', array('account' => $node)),
      'date' => $node->changed,
      'node' => $node,
      'extra' => $extra,
      'score' => $item->calculated_score,
      'snippet' => search_excerpt($keys, $node->rendered),
    );
  }

We can use updated code which works fine:

  $results = array();
  $submitted = variable_get('node_submitted_page', FALSE);
  foreach ($find as $item) {
    // Render the node.
    $node = node_load($item->sid);
    $build = node_view($node, 'search_result');
    unset($build['#theme']);
    $node->rendered = drupal_render($build);

    // Fetch comments for snippet.
    $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node);

    $extra = module_invoke_all('node_search_result', $node);

    $uri = entity_uri('node', $node);
    $result = array(
      'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE))),
      'type' => check_plain(node_type_get_name($node)),
      'title' => $node->title,
      'node' => $node,
      'extra' => $extra,
      'score' => $item->calculated_score,
      'snippet' => search_excerpt($keys, $node->rendered),
    );
    if ($submitted) {
      $result['user'] = theme('username', array('account' => $node));
      $result['date'] = $node->changed;
    }
    
    $results[] = $result;

  }
furamag’s picture

StatusFileSize
new1.17 KB

Here is patch to fix search results bug. Please review.
Note: I never created patches before. For this patch I used WinMerge. Let me know if I did something wrong.

furamag’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, search_results_submitted.patch, failed testing.

jhodgdon’s picture