Make WordPress Core

Ticket #27571: 27571.diff

File 27571.diff, 1.5 KB (added by wonderboymusic, 11 years ago)
  • src/wp-includes/class-wp-comment-query.php

     
    671671                        $orderby = "ORDER BY $orderby";
    672672                }
    673673
     674                if ( '*' === $fields ) {
     675                        $fields = $wpdb->comments . '.*';
     676                }
     677
    674678                $this->request = "SELECT $fields FROM $wpdb->comments $join $where $groupby $orderby $limits";
    675679
    676680                if ( $this->query_vars['count'] ) {
  • src/wp-includes/class-wp-comment.php

     
    211211        public function to_array() {
    212212                return get_object_vars( $this );
    213213        }
     214
     215        /**
     216         * Whether a comment has post from which to retrieve magic properties
     217         *
     218         * @since 4.4.0
     219         * @access public
     220         *
     221         * @param string $name
     222         * @return bool
     223         */
     224        public function __isset( $name ) {
     225                if (
     226                        0 === (int) $this->comment_post_ID
     227                        || property_exists( $this, $name )
     228                ) {
     229                        return;
     230                }
     231
     232                $post = get_post( $this->comment_post_ID );
     233                if ( $post ) {
     234                        return property_exists( $post, $name );
     235                }
     236        }
     237
     238        /**
     239         * Magic getter for $post properties
     240         *
     241         * @since 4.4.0
     242         * @access public
     243         *
     244         * @param string $name
     245         * @return mixed
     246         */
     247        public function __get( $name ) {
     248                $post = get_post( $this->comment_post_ID );
     249                if ( $post ) {
     250                        return $post->$name;
     251                }
     252        }
    214253}