Make WordPress Core

Changeset 60643


Ignore:
Timestamp:
08/17/2025 04:57:30 PM (13 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Move count() usage in wp_dashboard_recent_comments().

While the rule to discourage using functions like count() in a loop condition is a recommendation/best practice rule from the WordPress-Extra ruleset and does not directly apply to WordPress core, this is intended as a minor readability and code clarity improvement.

Follow-up to [10090], [17556], [20609], [26144].

Props krunal265, johnbillion, audrasjb, dhruvang21, SergeyBiryukov.
Fixes #56499.

File:
1 edited

Legend:

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

    r59159 r60643  
    10751075        }
    10761076
    1077         while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
    1078                 if ( ! is_array( $possible ) ) {
     1077        do {
     1078                $possible = get_comments( $comments_query );
     1079
     1080                if ( empty( $possible ) || ! is_array( $possible ) ) {
    10791081                        break;
    10801082                }
     
    10891091                        }
    10901092
    1091                         $comments[] = $comment;
    1092 
    1093                         if ( count( $comments ) === $total_items ) {
     1093                        $comments[]     = $comment;
     1094                        $comments_count = count( $comments );
     1095
     1096                        if ( $comments_count === $total_items ) {
    10941097                                break 2;
    10951098                        }
     
    10981101                $comments_query['offset'] += $comments_query['number'];
    10991102                $comments_query['number']  = $total_items * 10;
    1100         }
     1103        } while ( $comments_count < $total_items );
    11011104
    11021105        if ( $comments ) {
Note: See TracChangeset for help on using the changeset viewer.