Hello,
Working on a multi-language site.

When using the form on the top of the result page, I've got these 3 notices :

Notice : Undefined index: or in node_search_validate() (ligne 2738 in /modules/node/node.module).
    Notice : Undefined index: negative in node_search_validate() (ligne 2743 in /modules/node/node.module).
    Notice : Undefined index: phrase in node_search_validate() (ligne 2748 in /modules/node/node.module).

if I don't have custom_search enabled, I've got no messages and search system is doing his job has expected.
Seems like maybe the system didn't like the deactivation of the advanced search ? Or something else...

Thanks for your help.

Comments

anou’s picture

After searching a bit, seems like custom_search is not defining these 3 variables :

  1. $form_state['values']['or']
  2. $form_state['values']['negative']
  3. $form_state['values']['phrase']

I try to find where it should define them...

anou’s picture

I didn't had time to search a lot so I modified the node.module file (I know it's bad, but I'm naughty) :
Before line 2738, I insert :

if(!isset($form_state['values']['or'])){$form_state['values']['or']='';}
if(!isset($form_state['values']['negative'])){$form_state['values']['negative']='';}
if(!isset($form_state['values']['phrase'])){$form_state['values']['phrase']='';}

Hope someone find something else...
Cheers.

Zachmo’s picture

Version: 7.x-1.7 » 7.x-1.9
Priority: Normal » Major

I'm also having this issue. Looks like this is a quick fix from the previous post.

Changed priority cause it looks like it has been sitting for a while and needs to be addressed.

Zachmo’s picture

Ok, so it looks like this is only happening when you submit a search from the actual search page. When I submit a search from the "Search Form" block it doesn't run through the node_search_validate function so this error is never thrown.

Looking at the custom_search.module file it looks like the issue could have something to do with these lines...

106   if (!variable_get('custom_search_advanced_or_display', TRUE)) unset($form['advanced']['keywords']['or']);
107   if (!variable_get('custom_search_advanced_phrase_display', TRUE)) unset($form['advanced']['keywords']['phrase']);
108   if (!variable_get('custom_search_advanced_negative_display', TRUE)) unset($form['advanced']['keywords']['negative']);

Simply changing the unset function to setting the variable to an empty string, which is what the error is wining about, didn't work :(

jdanthinne’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
Status: Active » Needs review

In the DEV version, I've just changed

unset($form['advanced']['keywords']['or']);
unset($form['advanced']['keywords']['phrase']);
unset($form['advanced']['keywords']['negative']);

by

$form['advanced']['keywords']['or']['#type'] = 'hidden';
$form['advanced']['keywords']['phrase']['#type'] = 'hidden';
$form['advanced']['keywords']['negative']['#type'] = 'hidden';

and the error seems to be gone.
Please test and review next DEV.

steltere’s picture

I just uninstalled the release version and re-installed the dev version, and I'm still getting the error. I've doublechecked, and the changes you made to lines 110-112 are there. I've also cleared the cache and run cron, just in case there was something somehow left over from the previous version.

Still, no change.

MostlyGhostly’s picture

I also have the same error and made the changes suggested above - the error remains. I've reverted my file back to it's original state for the time being.

Any ideas?

MostlyGhostly’s picture

Status: Needs review » Active
rooby’s picture

Status: Active » Needs review
StatusFileSize
new4.27 KB

The problem is if you have the 'Display advanced search' checkbox unchecked then it unsets the whole 'advanced' parent element.

This patch fixes it for me.
(sorry about the semi-unrelated coding standards fixes, I was finding it hard to follow without those - I can remove them if preferred)

The main part is:

-        if (!variable_get('custom_search_results_advanced_search', TRUE)) unset($form['advanced']);
-
+        if (!variable_get('custom_search_results_advanced_search', TRUE)) {
+          $form['advanced']['#type'] = 'hidden';
+        }
adelka’s picture

I tried this solution, but it is not working for 7.x-1.9 version. The bug is still there :(

rooby’s picture

@adelka:

As mentioned in #5, there have been some fixes done in the dev version.
Then my patch in #9 adds to that.

So you currently have to be using the dev version, with the patch in #9, until 7.x-1.10 comes out.

soulston’s picture

The patch didn't work for me until I put an extra line break at the end?

All the credit goes to @rooby. I just added a line break.

rooby’s picture

I actually have commit access now so I will commit this soon.

jdanthinne’s picture

Status: Needs review » Fixed

I've just pushed the fix to the DEV version.
Thanks rooby.

Status: Fixed » Closed (fixed)

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