[wp-trac] [WordPress Trac] #26042: wp_save_post_revision() can compare against the wrong $last_revision post
WordPress Trac
noreply at wordpress.org
Thu May 22 18:18:14 UTC 2014
#26042: wp_save_post_revision() can compare against the wrong $last_revision post
-------------------------------------------------+-------------------------
Reporter: wonderboymusic | Owner:
Type: defect (bug) | wonderboymusic
Priority: normal | Status: closed
Component: Revisions | Milestone: Future
Severity: major | Release
Keywords: has-patch needs-unit-tests commit | Version:
4.0-early | Resolution: fixed
| Focuses:
-------------------------------------------------+-------------------------
Changes (by wonderboymusic):
* status: reopened => closed
* resolution: => fixed
Comment:
In [changeset:"28541"]:
{{{
#!CommitTicketReference repository="" revision="28541"
Apply `order` to each passed value for `orderby` in `WP_Query`:
* Since `orderby` in `WP_Query` can accept space-delimited sets, yet only
one `order` value: when multiple values are passed (and `DESC` is the
order), the default sort order `ASC` is being applied to all values before
the last in the set.
* There is a unit test that sporadically fails since 3.6 in
`tests/post/revision` due to multiple posts having the same `post_date`
from being added so rapidly
* When ordering revisions in `wp_get_post_revisions()`, order by
`post_date ID`
* Change the `order` value in `wp_get_post_revisions()` to `ASC`. This
will produce SQL like: `ORDER BY $wpdb->posts.post_date ASC,
$wpdb->posts.ID ASC`. Previously, this would have produced SQL like:
`ORDER BY $wpdb->posts.post_date DESC`, and with the addition of ` ID`:
`ORDER BY $wpdb->posts.post_date ASC, $wpdb->posts.ID DESC`. Clearly,
wrong. The original SQL produced: `ORDER BY $wpdb->posts.post_date DESC`.
As such, return the reversions in reverse order using `array_reverse()`.
Not doing so would break "Preview Changes."
* Add unit tests to assert that all of this works.
* All existing unit tests pass with the change to ordering multiple
`orderby`s in `WP_Query`.
* In the future, we should support independent `order` for each `orderby`,
see #17065.
Props SergeyBiryukov, wonderboymusic.
Fixes #26042.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26042#comment:29>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list