Make WordPress Core

Ticket #25775: 25775.viper007bond.patch

File 25775.viper007bond.patch, 1.9 KB (added by Viper007Bond, 11 years ago)

Changes existing filter behavior. :( See comments.

  • src/wp-includes/date.php

     
    153153        }
    154154
    155155        /**
    156          * Validates a column name parameter.
     156         * Validates a column name parameter and prepends the appropriate $wpdb table name.
    157157         *
    158158         * @since 3.7.0
    159159         * @access public
    160160         *
    161161         * @param string $column The user-supplied column name.
    162          * @return string A validated column name value.
     162         * @return string A validated column name value prepended by its $wpdb table name.
    163163         */
    164164        public function validate_column( $column ) {
     165                global $wpdb;
     166
    165167                $valid_columns = array(
    166                         'post_date', 'post_date_gmt', 'post_modified',
    167                         'post_modified_gmt', 'comment_date', 'comment_date_gmt'
     168                        'post_date'         => $wpdb->posts,
     169                        'post_date_gmt'     => $wpdb->posts,
     170                        'post_modified'     => $wpdb->posts,
     171                        'post_modified_gmt' => $wpdb->posts,
     172                        'comment_date'      => $wpdb->comments,
     173                        'comment_date_gmt'  => $wpdb->comments,
    168174                );
     175
    169176                /**
    170177                 * Filter the list of valid date query columns.
    171178                 *
    172179                 * @since 3.7.0
    173180                 *
    174                  * @param array $valid_columns An array of valid date query columns. Defaults are 'post_date', 'post_date_gmt',
    175                  *                             'post_modified', 'post_modified_gmt', 'comment_date', 'comment_date_gmt'
     181                 * @param array $valid_columns An array of valid date query columns, with the key being the column name and the value
     182                 *                             being the table name. See $valid_columns in WP_Date_Query::validate_column() for the defaults;
    176183                 */
    177                 if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) )
     184                $valid_columns = apply_filters( 'date_query_valid_columns', $valid_columns );
     185
     186                if ( ! isset( $valid_columns[ $column ] ) ) {
    178187                        $column = 'post_date';
     188                }
    179189
     190                $column = $valid_columns[ $column ] . '.' . $column;
     191
    180192                return $column;
    181193        }
    182194