Ticket #27283: 27283.diff
File 27283.diff, 3.0 KB (added by , 11 years ago) |
---|
-
src/wp-includes/date.php
167 167 public function validate_column( $column ) { 168 168 $valid_columns = array( 169 169 'post_date', 'post_date_gmt', 'post_modified', 170 'post_modified_gmt', 'comment_date', 'comment_date_gmt' 170 'post_modified_gmt', 'comment_date', 'comment_date_gmt', 171 'user_registered', 171 172 ); 172 173 /** 173 174 * Filter the list of valid date query columns. … … 175 176 * @since 3.7.0 176 177 * 177 178 * @param array $valid_columns An array of valid date query columns. Defaults are 'post_date', 'post_date_gmt', 178 * 'post_modified', 'post_modified_gmt', 'comment_date', 'comment_date_gmt' 179 * 'post_modified', 'post_modified_gmt', 'comment_date', 'comment_date_gmt', 180 * 'user_registered' 179 181 */ 180 182 if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) ) 181 183 $column = 'post_date'; -
src/wp-includes/user.php
690 690 $this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)"; 691 691 } 692 692 693 // Date queries are allowed for the user_registered field. 694 if ( ! empty( $qv['date_query'] ) && is_array( $qv['date_query'] ) ) { 695 $date_query = new WP_Date_Query( $qv['date_query'], 'user_registered' ); 696 $this->query_where .= $date_query->get_sql(); 697 } 698 693 699 /** 694 700 * Fires after the WP_User_Query has been parsed, and before 695 701 * the query is executed. -
tests/phpunit/tests/user.php
6 6 */ 7 7 class Tests_User extends WP_UnitTestCase { 8 8 9 function test_get_user_by_user_registered() { 10 11 $date_query_test_args = array(); 12 13 // users registered last 30 days 14 $date_query_test_args[] = array( 15 'after' => '-30 days' 16 ); 17 18 // users registered in current month 19 $date_query_test_args[] = array( 20 'month' => gmdate( 'n' ) 21 ); 22 23 // users registered dayofweek between 2 and 6 AND before 01.01.2014 24 $date_query_test_args[] = array( 25 array( 26 'dayofweek' => array( 2, 6 ), 27 'compare' => 'BETWEEN', 28 ), 29 array( 30 'before' => 'January 1st, 2014' 31 ), 32 'relation' => 'AND' 33 ); 34 35 foreach ( $date_query_test_args as $query_test_arg ) { 36 37 $user = new WP_User_Query( array( 38 'date_query' => $query_test_arg 39 ) ); 40 41 // creating a date_query-object to compare the WP_User_Query-Where with the WP_Date_Query-Date 42 $date_query = new WP_Date_Query( $query_test_arg, 'user_registered' ); 43 $this->assertEquals( $user->query_where, 'WHERE 1=1' . $date_query->get_sql() ); 44 45 } 46 47 } 48 9 49 function test_get_users_of_blog() { 10 50 // add one of each user role 11 51 $nusers = array();