[wp-trac] [WordPress Trac] #30478: Comment query results returned in an inconsistent order on some versions of MySQL
WordPress Trac
noreply at wordpress.org
Mon Nov 24 14:52:58 UTC 2014
#30478: Comment query results returned in an inconsistent order on some versions of
MySQL
--------------------------+------------------------------
Reporter: boonebgorges | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by boonebgorges):
The failing test in this case is `test_get_comments_by_user()`. That test
is not designed to assert anything about the *order* of comments returned
by `get_comments()`, so my first step will be to force
'orderby=comment_ID' for that test, in order to fix the build.
A true fix for this issue will mean adding a second column to the ORDER BY
clause for comment queries that will guarantee consistent order even when
there's a tie in the first column. That second column will probably be
'comment_ID', and the order (DESC/ASC) should be determined based on the
primary 'orderby'/'order' pair. That is,
'orderby=comment_date_gmt&order=desc' should translate to `ORDER BY
comment_date_gmt DESC, comment_ID DESC`;
'orderby=comment_date_gmt&order=asc' would be `ORDER BY comment_date_gmt
ASC, comment_id ASC`; 'orderby=comment_author_email&order=ASC' etc is a
coin-flip (probably DESC for consistency).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30478#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list