Hello,
I'm using fivestar and search modules. After node indexation the words SELECT, RATING, POOR, OKAY, GOOD, GREAT, AWESOME appears into search_index table. It's because fivestar module outputs it's code during execution _node_index_node. Is it possible to prevent this behavior?
Investigating this issue i found that following code change prevent this:
in fivestar.module in fivestar_nodeapi function (line 860 in 6.x-1.13) from
if ($node->build_mode != NODE_BUILD_PREVIEW && !isset($node->modr8_form_teaser) && variable_get('fivestar_'. $node->type, 0)) {
change to
if ($node->build_mode != NODE_BUILD_SEARCH_INDEX && $node->build_mode != NODE_BUILD_PREVIEW && !isset($node->modr8_form_teaser) && variable_get('fivestar_'. $node->type, 0)) {
Is this way correct?
Thank you.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chawl’s picture

Thank you grafsl, I confirm this is working and also turned this into a patch for 6.x-1.13.

Please someone commit this change on the next release, as this "appearing in searches" problem is really annoying.

Tx in advance.

chawl’s picture

Version: 6.x-1.x-dev » 6.x-1.13
Category: feature » bug
Priority: Normal » Critical
Status: Active » Needs review

Oops.

quicksketch’s picture

Priority: Critical » Normal
Status: Needs review » Fixed

Thanks chawl, committed.

Büke Beyond’s picture

Version: 6.x-1.13 » 6.x-1.x-dev
Priority: Normal » Critical
Status: Fixed » Needs review
FileSize
1.12 KB

This problem is not completely fixed. The above changes keeps the search index clean of the widget, fixing false search hits on words like "awesome".

However, the themed search module results still inject the widget and show words like "awesome" around any found content text. This is especially apparent with small node bodies.

There is actually a simple solution that I have tested for a couple of months:

      // When ($teaser || $page) == true, we ensure that:
      // $node->build_mode != NODE_BUILD_SEARCH_INDEX
      // && $node->build_mode != NODE_BUILD_PREVIEW
      // && the themed search module results do not render the widget
      if (($teaser || $page) && !isset($node->modr8_form_teaser) && variable_get('fivestar_'. $node->type, 0))
quicksketch’s picture

This conditional isn't quite clear to me. You're also preventing Fivestar from showing up in places where you would want it, say in a listing a Full nodes provided by Views. I think if you don't want the Fivestar widget in the full node view, you could simply disable it from the full view.

Büke Beyond’s picture

FileSize
1.22 KB

I have been testing Views listings with node Teaser displays, it has been rendering the widget correctly.

However, Full-page node listings in Views do suppress the widget as you describe, so here is a fix for that.

      // When ($teaser || $page || isset($node->view)) == true, we ensure that:
      // $node->build_mode != NODE_BUILD_SEARCH_INDEX
      // && $node->build_mode != NODE_BUILD_PREVIEW
      // && the themed Search module results do not render the widget
      // && full page node listings in Views do render the widget
      if (($teaser || $page || isset($node->view)) && !isset($node->modr8_form_teaser) && variable_get('fivestar_'. $node->type, 0)) {

I have been monitoring the value of $teaser, $page and $node->build_mode, during various events, node load, view, alter, preview, search results, views, cron search indexing time...

Whenever both $teaser and $page lack the value true (they sometimes have null, sometimes 0), either the $node->build_mode == NODE_BUILD_SEARCH_INDEX, NODE_BUILD_PREVIEW, the search results are being output, or Views is listing Full-page nodes..

You see, the widget needs to be suppressed in core Search module results, this is the main point of this patch.

quicksketch’s picture

Priority: Critical » Normal
Status: Needs review » Fixed
FileSize
955 bytes

After doing a little research, it turns out there's a build mode for "NODE_BUILD_SEARCH_RESULT". Adding this to list of build modes is an easy fix and much more clear about when the Fivestar widget is being omitted.

davegan’s picture

Has this also been fixed in the Drupal 5 version?

quicksketch’s picture

No, the Drupal 5 version is no longer being developed (patches still accepted though). This solution is not applicable to the Drupal 5 version because it did not have the $node->build_mode property.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.