I've been getting some weird bugs when running the search index with an installation of Webform that was updated from 2.4 to 3.9. I thought a way around this would be to add an option to skip the webform_node_view() process entirely based on a given variable.

Comments

damienmckenna’s picture

StatusFileSize
new1.53 KB
new1.52 KB

Patches for D6 and D7 to add a new 'webform_search_index' variable which defaults to 1, i.e. all content indexed.

damienmckenna’s picture

Status: Active » Needs review
damienmckenna’s picture

StatusFileSize
new1.57 KB
new1.57 KB

Updated patches that fix a major #facepalm-worthy bug - I wasn't checking the node's build mode so webforms were *always* being enabled/disabled based on the variable.

quicksketch’s picture

Status: Needs review » Needs work

This sounds like a reasonable option to me. Though "Index webform data" is a poor name in my opinion. That makes it sounds like the data submitted into the webform would be indexed. How about "Index webform forms"? Also we only need the checkbox if search module is enabled right? Also I don't think D6 has $node->build_mode, could you confirm?

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new1.61 KB
new1.6 KB
  • I updated the settings field's label and description.
  • D6 does have $node->build_mode, e.g. node_build_content() in node.module.
  • I added a check to both webform_node_view() and the settings form to see if the search module was enabled before displaying them.

Patches for D6 and D7 enclosed.

damienmckenna’s picture

StatusFileSize
new1.17 KB

For anyone who needs it, a patch for the 6.x-2.x branch to implement this functionality.

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new1.62 KB
new1.63 KB

In my testing I cleaned up this patch to suit my taste (using #access instead of an IF statement, code comments), but I found that this patch doesn't work in Drupal 7. Drupal 7 does not have the NODE_BUILD_SEARCH_INDEX constant at all, it uses $node->build_mode = 'search_index' instead.

I've updated the patches and committed them as attached to this comment.

damienmckenna’s picture

Thanks quicksketch!

Status: Fixed » Closed (fixed)

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

effulgentsia’s picture

Status: Closed (fixed) » Active

Is the new setting really needed? Webform module already implements webform_field_extra_fields(), so the administrator can remove the webform from the seach index by going to Manage Display for the content type (e.g., the Webform one by default, or one of the others for which webform is enabled), choosing to customize the "search index" view mode, and hiding the webform "extra field". While arguably the "Manage Display" UI has some discoverability problems, at least it's a common pattern, that once learned, can be used to manage display of other things attached to content, and for other purposes than just search index.

+++ b/includes/webform.admin.inc
@@ -108,6 +108,15 @@ function webform_admin_settings() {
+    '#description' => t('When selected, all Webform nodes will have their form components indexed by the search engine.'),

Is this description true? Does "Webform nodes" refer to nodes of type "Webform", or nodes of any type for which webforms are enabled? What if using Manage Display, you hide the webform "extra field" from the search index for one webform type, but not another? I don't think this checkbox overrides (or should override) that choice. For these reasons, I think it would make sense to remove this checkbox and just defer to the Manage Display UI.

quicksketch’s picture

Thanks @effulgentsia I think you're right on all counts. The change makes sense in Drupal 6 (I'm guessing that's what it was originally written for), since hook_content_extra_fields() doesn't affect display in Drupal 6.

Does "Webform nodes" refer to nodes of type "Webform", or nodes of any type for which webforms are enabled?

The latter is true, though for most sites "Webform nodes" and "Webform enabled content types" are the same thing, since most sites just leave Webform as the only Webform-enabled type.

So in short we should do two things:
- Remove the option from Drupal 7
- Leave the option in D6 but clarify its description

(That said, I wish this would have been opened as a separate ticket. I don't like fixing bugs in issues for "feature requests".)

danchadwick’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Re 6.x: There won't be further feature development in the X.x-3.x branches.
Re 7. Closing for lack of activity on a minor wording ambiguity.