WordPress.org

Support

Support » Plugins and Hacks » Relevanssi - A Better Search » [Resolved] Bug in relevanssi_default_post_ok

[Resolved] Bug in relevanssi_default_post_ok

  • There’s a bug in the relevanssi_default_post_ok function. The problem is that, although it receives a $post_ok value from earlier filter function(s), it disregards this received value and overwrites it with true or false depending on its own tests.

    The easiest solution is to add a, let’s say, $my_post_ok = true; declaration at the beginning of the function, then use this variable in the 6 instances where $post_ok was originally used, and finally end the function with a return ( $my_post_ok && $post_ok );. This way an originally false $post_ok value won’t suddenly become true and make posts that should be hidden reappear in the search.

    What do you think?

    http://wordpress.org/extend/plugins/relevanssi/

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

    @msaari

    Well, yeah, it’s not designed to care about the previous value =) It’s just if nothing catches in the default post ok function, the previous value will pass through.

    If you want to make sure your filter overrides the default value, you can set it to run after the default filter by adjusting the priorities.

    I suppose your suggestion does make sense.

    Plugin Author Mikko Saari

    @msaari

    I decided not to change this. If you want to make sure your function is not overridden by the default function, use a later priority or disable the default function.

    Disabling the default function had’t occurred to me. Yes, it makes sense in many ways. This is to show how I’m still a long way from being really proficient at customizing things in code. 🙂

    Another suggestion then: since the default function is quite fundamental, wouldn’t it make more sense to run it at priority 9 or lower?

    Plugin Author Mikko Saari

    @msaari

    Yeah, that would make sense.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Bug in relevanssi_default_post_ok’ is closed to new replies.
Skip to toolbar