Making WordPress.org

Opened 9 years ago

Closed 7 years ago

#1026 closed defect (bug) (fixed)

WordCamp wc-post-types: Session Table in Backend shows no sessions when ordering by Time

Reported by: pixolin's profile pixolin Owned by: kovshenin's profile kovshenin
Milestone: Priority: normal
Component: WordCamp Site & Plugins Keywords: good-first-bug has-patch
Cc:

Description

Just got slightly shocked that ordering the sessions by time* returns "No sessions found". For a split-second I was afraid, I managed to delete them all, but then was relieved to see all sessions again by ordering them by title or date.

*wp-admin/edit.php?post_type=wcb_session&orderby=_wcpt_session_time&order=asc

My guess is, something might be wrong with
trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php#L180

Attachments (1)

meta-1026.patch (912 bytes) - added by SergeyBiryukov 9 years ago.

Download all attachments as: .zip

Change History (5)

#1 @iandunn
9 years ago

  • Keywords good-first-bug added
  • Owner set to iandunn
  • Status changed from new to accepted

I'm seeing that too. WordCamp_Post_Types_Plugin::admin_pre_get_posts() mentions doing some voodoo to work around #wp23268, which is fixed now, so perhaps that can be removed.

Last edited 9 years ago by SergeyBiryukov (previous) (diff)

#2 @SergeyBiryukov
9 years ago

  • Keywords has-patch added; needs-patch removed

The current query:

SELECT SQL_CALC_FOUND_ROWS wc_46_posts.ID FROM wc_46_posts LEFT JOIN wc_46_postmeta ON ( wc_46_posts.ID = wc_46_postmeta.post_id ) LEFT JOIN wc_46_postmeta AS mt1 ON ( wc_46_posts.ID = mt1.post_id ) LEFT JOIN wc_46_postmeta AS mt2 ON (wc_46_posts.ID = mt2.post_id AND mt2.meta_key = '_wcpt_session_time' ) WHERE 1=1 AND ( 
wc_46_postmeta.meta_key = '_wcpt_session_time' 
AND 
( 
( mt1.meta_key = '_wcpt_session_time' AND CAST(mt1.meta_value AS CHAR) = '' ) 
OR 
mt2.post_id IS NULL
)
) AND wc_46_posts.post_type = 'wcb_session' AND (wc_46_posts.post_status = 'publish' OR wc_46_posts.post_status = 'future' OR wc_46_posts.post_status = 'draft' OR wc_46_posts.post_status = 'pending' OR wc_46_posts.post_status = 'cancel' OR wc_46_posts.post_status = 'failed' OR wc_46_posts.post_status = 'timeout' OR wc_46_posts.post_status = 'refund' OR wc_46_posts.post_status = 'private') GROUP BY wc_46_posts.ID ORDER BY wc_46_postmeta.meta_value+0 ASC LIMIT 0, 20

Note AND CAST(mt1.meta_value AS CHAR) = ''.

Per https://codex.wordpress.org/Class_Reference/WP_Query, there's no need to specify a value when using the 'EXISTS' or 'NOT EXISTS' comparisons in WordPress 3.9 and up.

A correct query would be:

SELECT SQL_CALC_FOUND_ROWS wc_46_posts.ID FROM wc_46_posts LEFT JOIN wc_46_postmeta ON ( wc_46_posts.ID = wc_46_postmeta.post_id ) LEFT JOIN wc_46_postmeta AS mt1 ON ( wc_46_posts.ID = mt1.post_id ) LEFT JOIN wc_46_postmeta AS mt2 ON (wc_46_posts.ID = mt2.post_id AND mt2.meta_key = '_wcpt_session_time' ) WHERE 1=1 AND ( 
wc_46_postmeta.meta_key = '_wcpt_session_time' 
AND 
( 
mt1.meta_key = '_wcpt_session_time' 
OR 
mt2.post_id IS NULL
)
) AND wc_46_posts.post_type = 'wcb_session' AND (wc_46_posts.post_status = 'publish' OR wc_46_posts.post_status = 'future' OR wc_46_posts.post_status = 'draft' OR wc_46_posts.post_status = 'pending' OR wc_46_posts.post_status = 'cancel' OR wc_46_posts.post_status = 'failed' OR wc_46_posts.post_status = 'timeout' OR wc_46_posts.post_status = 'refund' OR wc_46_posts.post_status = 'private') GROUP BY wc_46_posts.ID ORDER BY wc_46_postmeta.meta_value+0 ASC LIMIT 0, 20

See meta-1026.patch.

#3 @iandunn
9 years ago

  • Owner changed from iandunn to kovshenin
  • Status changed from accepted to assigned

#4 @coreymckrill
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

Looks like this was fixed in r3042.

Note: See TracTickets for help on using tickets.