Changeset 29760
- Timestamp:
- 09/23/2014 03:51:24 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r29750 r29760 960 960 961 961 $id = intval( $atts['id'] ); 962 if ( 'RAND' == $atts['order'] ) {963 $atts['orderby'] = 'none';964 }965 962 966 963 if ( ! empty( $atts['include'] ) ) { … … 1167 1164 * @type string $type Type of playlist to display. Accepts 'audio' or 'video'. Default 'audio'. 1168 1165 * @type string $order Designates ascending or descending order of items in the playlist. 1169 * Accepts 'ASC', 'DESC' , or 'RAND'. Default 'ASC'.1166 * Accepts 'ASC', 'DESC'. Default 'ASC'. 1170 1167 * @type string $orderby Any column, or columns, to sort the playlist. If $ids are 1171 1168 * passed, this defaults to the order of the $ids array ('post__in'). … … 1244 1241 1245 1242 $id = intval( $atts['id'] ); 1246 if ( 'RAND' == $atts['order'] ) {1247 $atts['orderby'] = 'none';1248 }1249 1243 1250 1244 $args = array( -
trunk/src/wp-includes/query.php
r29658 r29760 2796 2796 $where .= $search . $whichauthor . $whichmimetype; 2797 2797 2798 $rand = ( isset( $q['orderby'] ) && 'rand' === $q['orderby'] ); 2798 2799 if ( ! isset( $q['order'] ) ) { 2799 $q['order'] = 'DESC';2800 $q['order'] = $rand ? '' : 'DESC'; 2800 2801 } else { 2801 $q['order'] = $ this->parse_order( $q['order'] );2802 $q['order'] = $rand ? '' : $this->parse_order( $q['order'] ); 2802 2803 } 2803 2804 … … 2850 2851 2851 2852 if ( empty( $orderby ) ) { 2852 $orderby = "$wpdb->posts.post_date " .$q['order'];2853 } else {2853 $orderby = "$wpdb->posts.post_date " . $q['order']; 2854 } elseif ( ! empty( $q['order'] ) ) { 2854 2855 $orderby .= " {$q['order']}"; 2855 2856 } -
trunk/tests/phpunit/tests/post/query.php
r29027 r29760 832 832 ); 833 833 } 834 835 /** 836 * @ticket 29629 837 */ 838 function test_orderby() { 839 // 'rand' is a valid value 840 $q = new WP_Query( array( 'orderby' => 'rand' ) ); 841 $this->assertContains( 'ORDER BY RAND()', $q->request ); 842 $this->assertNotContains( 'ASC', $q->request ); 843 $this->assertNotContains( 'DESC', $q->request ); 844 845 // This isn't allowed 846 $q2 = new WP_Query( array( 'order' => 'rand' ) ); 847 $this->assertContains( 'ORDER BY', $q2->request ); 848 $this->assertNotContains( 'RAND()', $q2->request ); 849 $this->assertContains( 'DESC', $q2->request ); 850 851 // 'none' is a valid value 852 $q3 = new WP_Query( array( 'orderby' => 'none' ) ); 853 $this->assertNotContains( 'ORDER BY', $q3->request ); 854 $this->assertNotContains( 'DESC', $q3->request ); 855 $this->assertNotContains( 'ASC', $q3->request ); 856 857 // false is a valid value 858 $q4 = new WP_Query( array( 'orderby' => false ) ); 859 $this->assertNotContains( 'ORDER BY', $q4->request ); 860 $this->assertNotContains( 'DESC', $q4->request ); 861 $this->assertNotContains( 'ASC', $q4->request ); 862 863 // empty array() is a valid value 864 $q5 = new WP_Query( array( 'orderby' => array() ) ); 865 $this->assertNotContains( 'ORDER BY', $q5->request ); 866 $this->assertNotContains( 'DESC', $q5->request ); 867 $this->assertNotContains( 'ASC', $q5->request ); 868 } 834 869 }
Note: See TracChangeset
for help on using the changeset viewer.