When performing a search on a site I'm working on, I get an error:

"recoverable fatal error: Object of class stdClass could not be converted to string in /var/drupal-6.16/modules/search/search.pages.inc on line 102."

After doing some digging, I found that this function takes the $info array and implodes it into a string for use in $variables['info']. It handles the type, user and date portions fine, but blows out on the extra bit because there is a PHP object of the returned node in the array, which can't be converted properly into a string.

This leads me to believe that some module I'm using is inserting this (checking the $info array on a vanilla install is much simpler), but raises two issues for me:

1) How do I best deduce what module is inserting the entire node object into the $info array? If I can't deduce the culprit, where are the best places to strip out/manually convert this object prior to the call to template_preprocess_search_result()?
2) Should the Search module check for data that can't be cleanly converted to a string and strip it out or convert it manually?

Comments

molenick’s picture

I found the underlying issue - a module was returning $node in hook_nodeapi when it's passed by reference, which led to the node clobbering itself.

Good practice should prevent this issue, but I've seen other similar issues with this error and search. What would be the costs (other than time) of making it safer to use?

molenick’s picture

Category: bug » feature

Changing to "feature request" for additional info.

jhodgdon’s picture

Status: Active » Closed (won't fix)

Sorry, we don't normally put code in the core of Drupal to fix issues caused by misuse of core functions, or misunderstanding of how to implement hooks.

If this wrong implementation came from a contrib module, please file an issue on that module to get it fixed (or you can move this issue to that project).

molenick’s picture

Thanks, that's what I figured - while researching my issue I saw something similar from different modules, so I thought it would be worth asking. I wasn't sure if there would be proper use cases where an object would end up in the $info array, but reason tells me that likely isn't the case. Thanks!