Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#42426 closed defect (bug) (invalid)

Search by keyword in non-English language site doesn't work

Reported by: PT Guy Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8.3
Component: Query Keywords:
Focuses: Cc:


# The Query

$the_query = new WP_Query( array(
	's' => 'Лорем',
) );

# Result
No posts found.

# Reason

The executed query $the_query->request included placeholder strings:

wp_posts.post_title LIKE '{290b944af99425682ef70000028625991093545a19c3cd2ccbf53c91848c62a7}Лорем{290b944af99425682ef70000028625991093545a19c3cd2ccbf53c91848c62a7}'

which were added in parse_search() by $wpdb->prepare(), but were not removed before execution.

# Solution

global $wpdb;
add_filter( 'posts_request', array( $wpdb, 'remove_placeholder_escape' ), 10, 2 );

Change History (4)

#1 @PT Guy
3 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#2 @johnbillion
3 years ago

  • Milestone Awaiting Review deleted

#3 @SergeyBiryukov
3 years ago

For the record, $the_query->request does indeed contain escaped placeholders, but the resulting query appears to be correct and works as expected in my testing.

#4 @PT Guy
3 years ago

@SergeyBiryukov indeed.
But the placeholder was removed in query() function of the wpdb class, by the 'query' filter

add_filter( 'query', array( $this, 'remove_placeholder_escape' ), 0 );

Sorry for my mistake.

Note: See TracTickets for help on using tickets.