Skip to content

Commit

Permalink
Editor: Check get_user_count() instead of get_users() for the loc…
Browse files Browse the repository at this point in the history
…ked post notice.

This aims to avoid slowing down the post editing by using a cached value instead of calling `get_users()`, which can be slow when plugins add various filters to all `get_users()` calls, especially with meta value comparisons on large `user_meta` tables.

Follow-up to [24304], [24543], [41829], [53011], [53018].

Props berislav.grgicak, bor0, costdev.
See #55958.

git-svn-id: https://develop.svn.wordpress.org/trunk@59522 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Dec 16, 2024
1 parent 8eaaf53 commit f6fb194
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/wp-admin/edit-form-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@
if ( is_multisite() ) {
add_action( 'admin_footer', '_admin_notice_post_locked' );
} else {
$check_users = get_users(
array(
'fields' => 'ID',
'number' => 2,
)
);

if ( count( $check_users ) > 1 ) {
if ( get_user_count() > 1 ) {
add_action( 'admin_footer', '_admin_notice_post_locked' );
}

Expand Down

0 comments on commit f6fb194

Please sign in to comment.