Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #27266


Ignore:
Timestamp:
03/03/2014 09:33:14 PM (11 years ago)
Author:
TobiasBg
Comment:

helen: I think, dglingren doesn't want to search for attachments, he's just saying that

AND wp_posts.post_type IN ('post', 'page', 'attachment')

is contradicting with

AND (wp_posts.post_status = 'publish'
OR wp_posts.post_author = 1
AND wp_posts.post_status = 'private') 

because attachments always have a post_status of inherit.

The front end search does indeed result in this SQL query. I could not yet check if attachments can have other post_status values.

The list of post types comes from get_post_types( array('exclude_from_search' => false) ).

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27266 – Description

    initial v2  
    44
    55{{{
    6 SELECT SQL_CALC_FOUND_ROWS mladev_posts.ID
    7 FROM mladev_posts
     6SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
     7FROM wp_posts
    88WHERE 1=1
    9 AND (((mladev_posts.post_title LIKE '%Guatemala%')
    10 OR (mladev_posts.post_content LIKE '%Guatemala%'))
    11 AND ((mladev_posts.post_title LIKE '%IRF3%')
    12 OR (mladev_posts.post_content LIKE '%IRF3%')))
    13 AND mladev_posts.post_type IN ('post', 'page', 'attachment')
    14 AND (mladev_posts.post_status = 'publish'
    15 OR mladev_posts.post_author = 1
    16 AND mladev_posts.post_status = 'private')
     9AND (((wp_posts.post_title LIKE '%Guatemala%')
     10OR (wp_posts.post_content LIKE '%Guatemala%'))
     11AND ((wp_posts.post_title LIKE '%IRF3%')
     12OR (wp_posts.post_content LIKE '%IRF3%')))
     13AND wp_posts.post_type IN ('post', 'page', 'attachment')
     14AND (wp_posts.post_status = 'publish'
     15OR wp_posts.post_author = 1
     16AND wp_posts.post_status = 'private')
    1717ORDER BY (CASE
    18 WHEN mladev_posts.post_title LIKE '%Guatemala IRF3%'
     18WHEN wp_posts.post_title LIKE '%Guatemala IRF3%'
    1919THEN 1
    20 WHEN mladev_posts.post_title LIKE '%Guatemala%'
    21 AND mladev_posts.post_title LIKE '%IRF3%'
     20WHEN wp_posts.post_title LIKE '%Guatemala%'
     21AND wp_posts.post_title LIKE '%IRF3%'
    2222THEN 2
    23 WHEN mladev_posts.post_title LIKE '%Guatemala%'
    24 OR mladev_posts.post_title LIKE '%IRF3%'
     23WHEN wp_posts.post_title LIKE '%Guatemala%'
     24OR wp_posts.post_title LIKE '%IRF3%'
    2525THEN 3
    26 WHEN mladev_posts.post_content LIKE '%Guatemala IRF3%'
     26WHEN wp_posts.post_content LIKE '%Guatemala IRF3%'
    2727THEN 4
    28 ELSE 5 END), mladev_posts.post_date DESC
     28ELSE 5 END), wp_posts.post_date DESC
    2929LIMIT 0, 2
    3030}}}
    3131
    32 Although the `post_type` clause includes attachment, the `post_status` test always fails because attachments have a `post_status` of inherit.
    33 
    34 
     32Although the `post_type` clause includes `attachment`, the `post_status` test always fails because attachments have a `post_status` of `inherit`.