Bug, fails if menu_order is set in query
-
Using the plugin since a while, all worked fine.
For some feature now added a
$query->set( 'menu_order', 123 );
inpre_get_posts
.No more search results… ??
Did some debugging, a database error came up:
FUNCTION dbXXXXX.123AND does not exist for SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN [...] OR (c.post_content LIKE '%:"wysiwyg"%'))) WHERE 1=1 AND wp_posts.menu_order = 123AND (((c.post_name = b.meta_value) AND (a.meta_value LIKE '%searchterm%')) [...]
Seems a space is missing or on wrong side of the statement
AND wp_posts.menu_order = 123
, note the two spaces in front but none after it... WHERE 1=1 AND wp_posts.menu_order = 123AND (((c.post_name ..
Did not find where this statement is added, only found in Where.php:41 this:
$where = 'AND (' . implode(' OR ', $list) . ')';
Changed it to this, added a space in front:
$where = ' AND (' . implode(' OR ', $list) . ')';
Now the database error is gone, all fine, search results work again. ??
Proably not the correct place for a real fix, but works for now, maybe you find a better fix for this bug.
Thanks for the great plugin.
ACF: Better Search 3.4.1, WordPress 4.9.11
- The topic ‘Bug, fails if menu_order is set in query’ is closed to new replies.