[wp-trac] [WordPress Trac] #23873: Gallery shortcode orderby does not support multiple column sorting

WordPress Trac noreply at wordpress.org
Wed Mar 27 21:13:53 UTC 2013


#23873: Gallery shortcode orderby does not support multiple column sorting
-----------------------------+--------------------------
 Reporter:  dglingren        |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Shortcodes
  Version:  3.5.1            |   Severity:  normal
 Keywords:                   |
-----------------------------+--------------------------
 In wp-includes/media.php, function gallery_shortcode, lines 689-694 are:

 {{{
 // We're trusting author input, so let's at least make sure it looks like
 a valid orderby statement
 if ( isset( $attr['orderby'] ) ) {
         $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
         if ( !$attr['orderby'] )
                 unset( $attr['orderby'] );
 }
 }}}

 The sanitize_sql_orderby function requires commas between multiple column
 names. If you enter, for example orderby="menu_order ID", the lack of a
 comma causes the parameter to be deleted from the query.

 Just after this test, on line 698, a multi-column sort without the comma
 delimiter is used as the default value.

 If you enter commas to get past the sanitize_sql_orderby test, logic in
 wp-includes/query.php, function get_posts will not accept the commas
 (lines 2358 - 2361) and all but the last of the columns are ignored.

 This issue should be considered along with those raised in #17065 and
 #16584. Thank you.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23873>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list