Hello all,

I will try to write/describe my first issue/resolution in this great community of Drupal.

The problem has been encountered in the next situation:

  1. Enter a username in the searchbox
  2. Obtain a non result page under "content" tab (advanced search page)
  3. Switch to "user" tab where the user is found
  4. Click on a given user and obtain the error/notice

The error obtained is the same described in this isuue http://drupal.org/node/1227876 for the 7.x-1.x-dev version.

Notice: Undefined index: node en custom_search_preprocess_search_results() (línea 36 de .../sites/all/modules/custom_search/custom_search.pages.inc).
Notice: Trying to get property of non-object en custom_search_preprocess_search_results() (línea 36 de .../sites/all/modules/custom_search/custom_search.pages.inc).

Solution Proposed:

Change the line 36:
if ($result['node']->type == $node_type->type) $nbresults++;

With this code:

if(isset($result['node']->type) && $result['node']->type){
        	if ($result['node']->type == $node_type->type) $nbresults++;
        }

Don't know if it-s the best solution or approach, as I simply check if the $result['node']->type is set (exists) and it has a value (not empty), not shure if it might be best to check only for the $result['node'] (the object itself) and not the property (type), please feel free to correct this solution.

I know that in dev version the problem has been resolved, but as read in other suggestions is best to avoid dev version where possible, I hope this can be of help to someone.

I will read through how to create .git patches in order to post a full patch.

Comments

thedosmann’s picture

I was getting this:
Notice: Undefined property: stdClass::$type in custom_search_preprocess_search_results() (line 36 of /custom_search.pages.inc).
adding the above code fixed it for me also. It seems a lot of issues with php I run into here lately needs to check if the var is set or not, maybe a lot unsetting is going on.

custom_search-7.x-1.9
using solr
drupal-7.12

jdanthinne’s picture

Can you try with the latest DEV version and tell me if this bug is still there?

jdanthinne’s picture

Status: Active » Fixed

Ok, I've just found the bug. I was trying to display the content type filter on results, but shouldn't do that for the user search page.
Fixed it and pushed to DEV.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Forgot to put the error itself