Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I get this error on the a 404 page:
Notice: Trying to get property of non-object in search404_page() (line 216 of /sites/all/modules/search404/search404.module).
Apache solr search still displays search results fine. It shows up for anonymous users as well. Any idea how to fix it? Thanks!
Comment | File | Size | Author |
---|---|---|---|
#15 | search404-non_object_apachesolr_search-form-1736646-15.patch | 1.1 KB | heddn |
Comments
Comment #1
somatics CreditAttribution: somatics commentedI have this same problem, every time; so my dblogs are quite full of this error.
Comment #2
zyxware CreditAttribution: zyxware commented@cmejo / @somatics - Thanks for reporting this error. I will need a bit of debugging help to solve this problem.
To solve the symptom you can replace the following line (line 416)
with the following.
This should take care of the notices. Now we will need to figure out what causes this problem. Can you please try dpm($form) above the if condition and see what where is the search page set in the $form array. Are you using the latest version of the apache_solr module?
Comment #3
zyxware CreditAttribution: zyxware commentedEdit: Removing duplicate post.
Comment #4
cmejo CreditAttribution: cmejo commented@xyzware Thanks for getting back to me. I don't have a line 416 in search404.module... I have it listed here:
Is it okay to replace that line there? Were you using the dev version to get it at line 416? Thanks!
Comment #5
somatics CreditAttribution: somatics commentedI'm not in a position just now to manually patch the file, unfortunately. I don't understand the other thing you're asking me to do to troubleshoot. Can you please clarify what you want me to do?
Comment #6
zyxware CreditAttribution: zyxware commented@cmejo - You can replace that last line starting with
$form['#action'] =
and replace it with the code I gave earlier. The code only adds an if condition to test the existence of the variables being used in the line to prevent the notice you are getting.dpm($form);
will print out the full form array that is returned from the drupal_get_form function call. You have to add it just after the line starting with$form = drupal_get_form('apachesolr_search_...
. The problem apparently is that solr is returning something and the code is expecting something else. Do note that dpm will require the devel module to be enabled. You will probably want to do it on the dev environment of your site.@somatics - The code I gave above should help prevent the notice messages flooding your dblog. Please see above for dpm.
Also can you also please let me know of the versions of solr and search404 modules used.
Comment #7
somatics CreditAttribution: somatics commentedWe're on Drupal 7.15 and using…
Comment #8
zyxware CreditAttribution: zyxware commented@somatics - It looks like you are using the latest versions. I will need to see the dpm output before I can debug this further.
Comment #9
cmejo CreditAttribution: cmejo commented@zyxware
Thanks! The code worked. I have devel installed and put dpm($form) on line 215 and got quite a bit of info. Is there something specific you are looking for?
Array 25 elements
#id (String, 11 characters ) search-form
#attributes (Array, 1 element)
#search_page (Array, 10 elements)
basic (Array, 17 elements)
#form_id (String, 41 characters ) apachesolr_search_custom_page_search_form | (Callback) apachesolr_search_custom_page_search_form();
#type (String, 4 characters ) form
#build_id (String, 48 characters ) form-eTITT1d4LQ3fLIhQPFwTsahGhIWIrMw8NGSo_Ik8DJM
form_build_id (Array, 18 elements)
#token (String, 41 characters ) apachesolr_search_custom_page_search_form | (Callback) apachesolr_search_custom_page_search_form();
form_token (Array, 17 elements)
form_id (Array, 18 elements)
#method (String, 4 characters ) post
#action (String, 7 characters ) /xmtext
#theme_wrappers (Array, 1 element)
#tree (Boolean) FALSE
#parents (Array, 0 elements)
#validate (Array, 0 elements)
#submit (Array, 1 element)
#theme (Array, 1 element)
#processed (Boolean) FALSE
#defaults_loaded (Boolean) TRUE
#required (Boolean) FALSE
#title_display (String, 6 characters ) before
#array_parents (Array, 0 elements)
#sorted (Boolean) TRUE
Let me know as I'm glad to help you with this issue!
Comment #10
zyxware CreditAttribution: zyxware commented@cmejo - Thanks for the debug information.Can you please confirm that there is a string inside the $form['#search_page'] with key 'search_path' and that this is the solr search page path on your site. dpm($form['#search_page']['search_path']) should tell you this.
Comment #11
cmejo CreditAttribution: cmejo commentedI added the above code with a semicolon and saw a green box that says "search/site" and the regular this page doesn't exist, here is a search red box. Nothing relating to devel appears. I can confirm that it is the solr search page as it allows for filtering (faceted search). Thanks!
Comment #12
ecarty CreditAttribution: ecarty commentedI am seeing this Notice also, however, if I change line 216 of search404.module from:
$form['#action'] = '/' . $form['#search_page']->search_path . $form['#action'];
to
$form['#action'] = '/' . $form['#search_page']['search_path'] . $form['#action'];
I don't get the notice message.
My understanding is that $form['#search_page'] is an array, but the '$form['#search_page']->' syntax is addressing it as an object - is this right?
Comment #13
cbrody CreditAttribution: cbrody commentedI can confirm that the change at #12 fixes a problem where the search form destination was being set to @keys with no preceding URL.
Comment #14
JordanMagnuson CreditAttribution: JordanMagnuson commented#12 fixed this for me as well.
Also using 7.x with latest apachesolr.
Comment #15
heddn#12 in a patch
Comment #16
heddnComment #17
JordanMagnuson CreditAttribution: JordanMagnuson commented4 confirmed working (if counting #12 and #15). Setting to RTBC.
Comment #18
zyxware CreditAttribution: zyxware commentedThis has been committed to the 7.x-1.x branch