• On every admin page this gets logged (I removed the full paths):

    
    [31-Oct-2016 09:05:35 UTC] PHP Notice:  is_search was called <strong>incorrectly</strong>. Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.) in wp-includes/functions.php on line 3897
    [31-Oct-2016 09:05:35 UTC] PHP Notice:  is_search was called <strong>incorrectly</strong>. Conditional query tags do not work before the query is run. Before then, they always return false. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.1.) in wp-includes/functions.php on line 3897
    [31-Oct-2016 09:05:35 UTC] PHP Notice:  Trying to get property of non-object in plugins/relevanssi/lib/search.php on line 23
    

    When looking at the relevanssi_query function I can see there are some things off (e.g. the above mentioned is_search()). Generally I think this function should be refactored, e.g.

    * return early if search is not activated for admin
    * use the passed $query object instead of referencing the global object

    I’d be happy to contribute an updated version of the function, if you accept pull requests (or similar).

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter alpipego

    (@alpipego)

    This would be the version with small changes: https://gist.github.com/alpipego/44496e1e9585d956954fef224f0c31af

    Plugin Author Mikko Saari

    (@msaari)

    What’s going on in your site that’s causing those errors? It’s not just Relevanssi; I don’t get anything like that on my sites.

    Also, changing the query object is not a small change. It’s a very drastic change that needs to be tested thoroughly.

    Adding the check for missing $wp_query is certainly possible.

    Thread Starter alpipego

    (@alpipego)

    I totally agree that it is most possibly conflicting code in this one.

    But you even state it in your code comments that you are not sure if the query is set up correctly (e.g. in ajax calls). I am not changing the query object at all, I am just using the object that gets passed to the filter anyhow. Does not have to be changed at all… but why do you then pass a second parameter to the function that never gets used?

    Plugin Author Mikko Saari

    (@msaari)

    It is possible to call relevanssi_do_query() directly, using any query object as a parameter. That’s why the parameter is there.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘is_search was called incorrectly’ is closed to new replies.