• Resolved stv11c

    (@stv11c)


    Hi, this seems to be a recent issue where an empty search, or just searching with one space causes a Fatal error.

    Fatal error: Allowed memory size of 134217728 btyes exhausted (tried to allocate 20480 bytes) in data/www/vhosts/DOMAINNAME/wp-includes/wp-db.php on line 1972

    When I deactivate plugin it works fine. Any ideas?

    THANKS!

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

    (@msaari)

    The behaviour for empty searches was changed to just run a search, and if there are no filtering parameters, the search will match all posts, which may lead to an out of memory error.

    Here’s a fix:

    add_filter( 'relevanssi_search_filters', 'rlv_empty_search', 10 );
    function rlv_empty_search( $args ) {
    	if ( empty( $args['q'] ) ) {
    		$args['q'] = 'gdfkjgdkfgdfgdfgdf';
    	}
        return $args;
    }

    I’ll look into this issue in the next version.

    Thread Starter stv11c

    (@stv11c)

    Hi Mikko, thanks for the quick reply and that worked! Also great plugin!

    Some notes for the solutions I tried which may assist with your debugging:
    – The issue only happened on production server and worked on my local dev environment, however the empty searches were slow on local. This made it difficult to locate the issue as the error only happened on prod.
    – Even with Paging on the search results the memory issue occurs.
    – Even with a filter on the main wordpress query to not return results on empty searches, the issue still persisted.
    – I have a feeling only sites with hundreds of search results will experience this, and the smaller sites may not.

    Hope that helps
    Thanks

    Plugin Author Mikko Saari

    (@msaari)

    The problem is that an empty search fetches the whole Relevanssi database. That’s just too much in many cases. On a very small site, that’s not a problem, and on a large enough site where the throttle is enabled, it’s not a problem.

    The solution is to make sure the throttle is always enabled when doing a termless search. This will be fixed in the next version, and if you want to try the fix now, make sure you’re running 4.3.4 and replace lib/search.php with this file: https://github.com/msaari/relevanssi/blob/master/lib/search.php

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Empty search or just a space causes WP error’ is closed to new replies.