• Resolved dreamingfifi

    (@dreamingfifi)


    Hi there! I’ve got the free versin of your plugin, which is really useful for helping people find stuff in the multiple databases of my website. But right now, something weird is happening.

    I’m at a loss for what is causing this error. It shows about fifty of these (I suspect the same number as there are results), then under that, lists the search results.

    `Notice: Trying to get property ‘post_title’ of non-object in /srv/users/serverpilot/apps/realelvish/public/wp-content/plugins/relevanssi/lib/search.php on line 484

    Notice: Trying to get property ‘post_content’ of non-object in /srv/users/serverpilot/apps/realelvish/public/wp-content/plugins/relevanssi/lib/search.php on line 487`

    I have already tried deactivating all of my plugins and reactivating to find one that could be messing with it – and no luck.

    Any help would be appreciated!

    Fiona

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi is doing the exact match bonus there, but when it tries to fetch a post object from the cache to check if the exact match bonus should be applied or not, it’s not getting a post object, but instead something else. That something else is not an object, and doesn’t have the post_title or post_object fields.

    Disabling the exact match bonus should make this error go away, but of course doesn’t fix the root cause. What that is, is a bit of a mystery for me at the moment – the Relevanssi cache should only ever have post objects.

    If you want to do a bit of digging, you can find the problematic lines in Relevanssi’s /lib/search.php file. They look like this:

    if ( $exact_match_bonus ) {
    	$post    = relevanssi_get_post( $match->doc );
    	$clean_q = str_replace( array( '"', '”', '“' ), '', $q );
    	if ( $clean_q ) {
    		if ( stristr( $post->post_title, $clean_q ) !== false ) {
    			$match->weight *= $exact_match_boost['title'];
    		}
    		if ( stristr( $post->post_content, $clean_q ) !== false ) {
    			$match->weight *= $exact_match_boost['content'];
    		}
    	}
    }

    You can then add

    var_dump( $post );

    after the line

    $post = relevanssi_get_post( $match->doc );

    and then do a search. What does that print out?

    Thread Starter dreamingfifi

    (@dreamingfifi)

    Well, now it’s even more messed up. Can I undo it now? It’s FAR too big to post here. And it includes an entire other page before the search page.

    Plugin Author Mikko Saari

    (@msaari)

    Yes, it’s supposed to look messed up, and yes, undo it as soon as you’ve seen what it prints out, it’s just for debugging.

    Instead of var_dump( $post );, what if you add this to the same spot:

    if ( !is_object($post)) var_dump($post);

    What does that print out? Probably much less stuff.

    Thread Starter dreamingfifi

    (@dreamingfifi)

    And… looks like the original problem. The line numbers changed, but nothing else.

    Plugin Author Mikko Saari

    (@msaari)

    It’s not the same as the original: it’s printing NULL there and that’s the problem. Instead of post objects, Relevanssi is seeing NULL, which causes the error. Of course it makes no sense to have NULL values at that point…

    You can try replacing the /lib/common.php file with this file: https://github.com/msaari/relevanssi/blob/master/lib/common.php

    Does that remove the error messages?

    Thread Starter dreamingfifi

    (@dreamingfifi)

    Nope – still has the same error, NULL included.

    Plugin Author Mikko Saari

    (@msaari)

    At this point I would just suggest disabling the exact match bonus.

    Thread Starter dreamingfifi

    (@dreamingfifi)

    Where do I find this setting?

    Thread Starter dreamingfifi

    (@dreamingfifi)

    Nevermind, I found it. Thank you! That solved the problem.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Weird error – “Notice: Trying to property…”’ is closed to new replies.