WordPress.org

Make WordPress Core

Changeset 51285


Ignore:
Timestamp:
06/30/2021 05:43:29 PM (3 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Remove redundant type casting to array in WP_Query::get_posts().

This brings some consistency with other instances of using get_post_stati() in core.

get_post_stati() always returns an array, so the type casting is not needed.

Follow-up to [13172].

See #53359.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-query.php

    r51276 r51285  
    25482548                    $public_statuses = get_post_stati( array( 'public' => true ) );
    25492549                    $status_clauses  = array();
    2550                     foreach ( (array) $public_statuses as $public_status ) {
     2550                    foreach ( $public_statuses as $public_status ) {
    25512551                        $status_clauses[] = "{$wpdb->posts}.post_status = '$public_status'";
    25522552                    }
     
    25612561                            )
    25622562                        );
    2563                         foreach ( (array) $admin_all_statuses as $admin_all_status ) {
     2563                        foreach ( $admin_all_statuses as $admin_all_status ) {
    25642564                            $type_where .= " OR {$wpdb->posts}.post_status = '$admin_all_status'";
    25652565                        }
     
    25702570                        $read_private_cap = $queried_post_type_object->cap->read_private_posts;
    25712571                        $private_statuses = get_post_stati( array( 'private' => true ) );
    2572                         foreach ( (array) $private_statuses as $private_status ) {
     2572                        foreach ( $private_statuses as $private_status ) {
    25732573                            $type_where .= current_user_can( $read_private_cap ) ? " \nOR {$wpdb->posts}.post_status = '$private_status'" : " \nOR ({$wpdb->posts}.post_author = $user_id AND {$wpdb->posts}.post_status = '$private_status')";
    25742574                        }
  • trunk/src/wp-includes/link-template.php

    r51121 r51285  
    18731873        $private_states = get_post_stati( array( 'private' => true ) );
    18741874        $where         .= " AND ( p.post_status = 'publish'";
    1875         foreach ( (array) $private_states as $state ) {
     1875        foreach ( $private_states as $state ) {
    18761876            if ( current_user_can( $read_private_cap ) ) {
    18771877                $where .= $wpdb->prepare( ' OR p.post_status = %s', $state );
Note: See TracChangeset for help on using the changeset viewer.