Make WordPress Core


Ignore:
Timestamp:
09/03/2015 06:16:35 PM (9 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/class-wp-comment-query.php

    r33750 r33891  
    666666         * @param WP_Comment_Query &$this    Current instance of WP_Comment_Query, passed by reference.
    667667         */
    668         $comments = apply_filters_ref_array( 'the_comments', array( $results, &$this ) );
     668        $_comments = apply_filters_ref_array( 'the_comments', array( $results, &$this ) );
     669
     670        // Convert to WP_Comment instances
     671        $comments = array_map( 'get_comment', $_comments );
    669672
    670673        wp_cache_add( $cache_key, $comments, 'comment' );
Note: See TracChangeset for help on using the changeset viewer.