[wp-hackers] Possible Wordpress or MySQL bug on different Ubuntu versions?
Otto
otto at ottodestruct.com
Wed Jan 30 22:07:18 UTC 2013
On Wed, Jan 30, 2013 at 3:29 PM, Roberto Sanchez
<roberto at digitalbrands.com> wrote:
> The query could return many posts with the same 'score', and here is where
> the problem starts. The query returns posts correctly ordered by 'score',
> but if I have for example 20 posts in a row with the same 'score', there's
> no guarantee it would return all those posts in the same order.
Oh, sorry, I missed this bit before.
No, this is not a MySQL bug, nor is it a WordPress bug. If you specify
an order in SQL, and two rows have the same value, then their order is
undefined and not guaranteed. The fact that MySQL returns them in any
particular order is not a constant nor absolute, and may change
between versions, phases of the moon, that sort of thing.
Your solution isn't really "hacky" so much as it is necessary, because
you want a well-defined order but are using an ordering system (score,
in your case) that is not well-defined. Adding the ID onto it makes it
unique and well-defined.
The fact that it changed in some version probably had something to do
with the way MySQL reads or stores data, or whatever. Point being it's
not a bug because it is undefined behavior to order by a field with
more than one of the same value in it.
-Otto
More information about the wp-hackers
mailing list