[wp-trac] [WordPress Trac] #35692: Allow seed value to be passed to WP_Query when using random ordering

WordPress Trac noreply at wordpress.org
Mon Feb 15 14:19:05 UTC 2016


#35692: Allow seed value to be passed to WP_Query when using random ordering
-------------------------------------------------+-------------------------
 Reporter:  hlashbrooke                          |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Query                                |  Review
 Severity:  normal                               |     Version:  trunk
 Keywords:  has-patch needs-unit-tests 2nd-      |  Resolution:
  opinion                                        |     Focuses:
-------------------------------------------------+-------------------------

Comment (by hlashbrooke):

 Replying to [comment:3 boonebgorges]:
 > There's something about this syntax that feels wrong to me. `$seed` is
 not a very transparent parameter name. And passing around a `$seed`
 parameter when invoking `parse_orderby()` seems somehow too ad hoc.
 >
 > Here's an idea: allow `orderby` to accept `RAND(3)` in addition to
 `RAND`. We would need some validation to make sure it's a integer. But it
 keeps the syntax much simpler and, IMO, intuitive for devs.

 That's a fair point - the validation there would be an issue, but not a
 huge one. The part that would be a bit more complex is that the `orderby`
 parameter is validated against a list of allowed options and if we allowed
 that to have a value of `rand(3)` then it would mean that the validation
 there would need to be modified quite heavily.

 I do tend to agree that having the `$seed` parameter passed around like
 this does seem a little too ad hoc, but it was the best implementation
 that I could think of on a first pass - I'll put some more thought into it
 though and see what I can come up with.

 Do you perhaps have a better parameter name than `seed` if we were to
 continue to use that as a separate parameter?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35692#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list