WP_Query generated SQL contains strings surrounding LIKE statements

0

As I am progressing more in my project. I came across a point where I checked the query that is being generated.

Right now im working on an advanced-search for my project.

When I check the query some very long strings get inserted surrouding a LIKE statement:

When I check

<?php 
    echo $query->request;
?>

I get the following result.

SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID 
FROM wp_posts  
WHERE 1=1  
AND (((wp_posts.post_title 
    LIKE '{79c7cacde467add48541d677feea079c7cacde467add48541d677feea023253}tepp{79c7cacde467add48541d677feea079c7cacde467add48541d677feea023253}') 
        OR (wp_posts.post_excerpt 
            LIKE '{79c7cacde467add48541d677feea079c7cacde467add48541d677feea023253}tepp{79c7cacde467add48541d677feea079c7cacde467add48541d677feea023253}') 
        OR (wp_posts.post_content 
            LIKE '{79c7cacde467add48541d677feea079c7cacde467add48541d677feea023253}tepp{79c7cacde467add48541d677feea079c7cacde467add48541d677feea023253}')))  
    AND wp_posts.post_type = 'post' 
    AND (wp_posts.post_status = 'publish' 
        OR wp_posts.post_status = 'future' 
        OR wp_posts.post_status = 'draft' 
        OR wp_posts.post_status = 'pending' 
        OR wp_posts.post_status = 'private')  
    ORDER BY wp_posts.post_title 
    LIKE '{79c7cacde467add48541d677feea079c7cacde467add48541d677feea023253}tepp{79c7cacde467add48541d677feea079c7cacde467add48541d677feea023253}' 
    DESC, wp_posts.post_date 
    DESC 
    LIMIT 0, 5

I’ve changed the string in case it holds any sensible data that can be reproduced.

However the query returns the right (expected) values.

$q = sanitize_text_field( trim($_POST['q']) );
$query = new WP_Query( array(
    'post_type' => 'post',
    's' => $q, // current search term 'tepp'
) ); ?>

Where are those strings coming from?

Link: WP_Query generated SQL contains strings surrounding LIKE statements
Source: Stack WordPress

Share.

About Author

Leave A Reply