[wp-trac] [WordPress Trac] #27266: Front end search for attachment title cannot succeed
WordPress Trac
noreply at wordpress.org
Mon Mar 3 21:33:14 UTC 2014
#27266: Front end search for attachment title cannot succeed
--------------------------+------------------------------
Reporter: dglingren | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Changes (by TobiasBg):
* keywords: close =>
Old description:
> This is somewhat related to ticket #22556 but affects all queries that
> use the keyword search parameter, 's'.
>
> Typing an attachment's title into the "front end" search box generated
> this query:
>
> {{{
> SELECT SQL_CALC_FOUND_ROWS mladev_posts.ID
> FROM mladev_posts
> WHERE 1=1
> AND (((mladev_posts.post_title LIKE '%Guatemala%')
> OR (mladev_posts.post_content LIKE '%Guatemala%'))
> AND ((mladev_posts.post_title LIKE '%IRF3%')
> OR (mladev_posts.post_content LIKE '%IRF3%')))
> AND mladev_posts.post_type IN ('post', 'page', 'attachment')
> AND (mladev_posts.post_status = 'publish'
> OR mladev_posts.post_author = 1
> AND mladev_posts.post_status = 'private')
> ORDER BY (CASE
> WHEN mladev_posts.post_title LIKE '%Guatemala IRF3%'
> THEN 1
> WHEN mladev_posts.post_title LIKE '%Guatemala%'
> AND mladev_posts.post_title LIKE '%IRF3%'
> THEN 2
> WHEN mladev_posts.post_title LIKE '%Guatemala%'
> OR mladev_posts.post_title LIKE '%IRF3%'
> THEN 3
> WHEN mladev_posts.post_content LIKE '%Guatemala IRF3%'
> THEN 4
> ELSE 5 END), mladev_posts.post_date DESC
> LIMIT 0, 2
> }}}
>
> Although the `post_type` clause includes attachment, the `post_status`
> test always fails because attachments have a `post_status` of inherit.
New description:
This is somewhat related to ticket #22556 but affects all queries that use
the keyword search parameter, 's'.
Typing an attachment's title into the "front end" search box generated
this query:
{{{
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
WHERE 1=1
AND (((wp_posts.post_title LIKE '%Guatemala%')
OR (wp_posts.post_content LIKE '%Guatemala%'))
AND ((wp_posts.post_title LIKE '%IRF3%')
OR (wp_posts.post_content LIKE '%IRF3%')))
AND wp_posts.post_type IN ('post', 'page', 'attachment')
AND (wp_posts.post_status = 'publish'
OR wp_posts.post_author = 1
AND wp_posts.post_status = 'private')
ORDER BY (CASE
WHEN wp_posts.post_title LIKE '%Guatemala IRF3%'
THEN 1
WHEN wp_posts.post_title LIKE '%Guatemala%'
AND wp_posts.post_title LIKE '%IRF3%'
THEN 2
WHEN wp_posts.post_title LIKE '%Guatemala%'
OR wp_posts.post_title LIKE '%IRF3%'
THEN 3
WHEN wp_posts.post_content LIKE '%Guatemala IRF3%'
THEN 4
ELSE 5 END), wp_posts.post_date DESC
LIMIT 0, 2
}}}
Although the `post_type` clause includes `attachment`, the `post_status`
test always fails because attachments have a `post_status` of `inherit`.
--
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 `attachment`s always have a `post_status` of `inherit`.
The front end search does indeed result in this SQL query. I could not yet
check if `attachment`s can have other `post_status` values.
The list of post types comes from `get_post_types(
array('exclude_from_search' => false) )`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27266#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list