WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/03/2015 06:16:35 PM (6 years ago)
Author:
wonderboymusic
Message:

Introduce WP_Comment class to model/strongly-type rows from the comments database table. Inclusion of this class is a pre-req for some more general comment cleanup and sanity.

  • Takes inspiration from WP_Post and adds sanity to comment caching.
  • Clarifies when the current global value for $comment is returned. The current implementation in get_comment() introduces side effects and an occasion stale global value for $comment when comment caches are cleaned.
  • Strongly-types @param docs
  • This class is marked final for now

Props wonderboymusic, nacin.

See #32619.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r33734 r33891  
    31873187            $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
    31883188
    3189             $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits");
     3189            $comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits");
     3190            // Convert to WP_Comment
     3191            $this->comments = array_map( 'get_comment', $comments );
    31903192            $this->comment_count = count($this->comments);
    31913193
     
    35583560
    35593561            $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits";
    3560             $this->comments = $wpdb->get_results($comments_request);
     3562            $comments = $wpdb->get_results($comments_request);
     3563            // Convert to WP_Comment
     3564            $this->comments = array_map( 'get_comment', $comments );
    35613565            $this->comment_count = count($this->comments);
    35623566        }
     
    38133817
    38143818    /**
    3815      * Iterate current comment index and return comment object.
     3819     * Iterate current comment index and return WP_Comment object.
    38163820     *
    38173821     * @since 2.2.0
    38183822     * @access public
    38193823     *
    3820      * @return object Comment object.
     3824     * @return WP_Comment Comment object.
    38213825     */
    38223826    public function next_comment() {
Note: See TracChangeset for help on using the changeset viewer.