Skip to content

Commit db9f744

Browse files
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. Built from https://develop.svn.wordpress.org/trunk@60643 git-svn-id: http://core.svn.wordpress.org/trunk@59979 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 669bacd commit db9f744

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

wp-admin/includes/dashboard.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,10 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
10741074
$comments_query['status'] = 'approve';
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
}
10811083

@@ -1088,16 +1090,17 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
10881090
continue;
10891091
}
10901092

1091-
$comments[] = $comment;
1093+
$comments[] = $comment;
1094+
$comments_count = count( $comments );
10921095

1093-
if ( count( $comments ) === $total_items ) {
1096+
if ( $comments_count === $total_items ) {
10941097
break 2;
10951098
}
10961099
}
10971100

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 ) {
11031106
echo '<div id="latest-comments" class="activity-block table-view-list">';

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.9-alpha-60642';
19+
$wp_version = '6.9-alpha-60643';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)