From d5c9ae5bd56bf86259af25c29a19511d4bf1969f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 6 Feb 2025 12:22:22 +0000 Subject: [PATCH] Coding Standards: Use strict comparison in `media_upload_library_form()`. Includes bringing some consistency with a similar fragment in `WP_List_Table::months_dropdown()`. Follow-up to [3724], [7062], [15491], [59755]. Props aristath, poena, afercia, SergeyBiryukov. See #62279. git-svn-id: https://develop.svn.wordpress.org/trunk@59767 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-list-table.php | 4 +- src/wp-admin/includes/media.php | 43 +++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index 3a65e015d5..924cc7db30 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -780,9 +780,9 @@ class WP_List_Table { printf( "\n", selected( $selected_month, $year . $month, false ), - esc_attr( $arc_row->year . $month ), + esc_attr( $year . $month ), /* translators: 1: Month name, 2: 4-digit year. */ - sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) + esc_html( sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) ) ); } ?> diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 24dfef62f5..73a2585f84 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -2845,38 +2845,37 @@ function media_upload_library_form( $errors ) {
get_results( + "SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month + FROM $wpdb->posts + WHERE post_type = 'attachment' + ORDER BY post_date DESC" + ); - $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; + $month_count = count( $months ); + $selected_month = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; - $arc_result = $wpdb->get_results( $arc_query ); - - $month_count = count( $arc_result ); - $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0; - - if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { + if ( $month_count && ( 1 !== $month_count || 0 !== (int) $months[0]->month ) ) { ?>