Make WordPress Core

Changeset 55183


Ignore:
Timestamp:
02/01/2023 10:15:04 PM (4 years ago)
Author:
joedolson
Message:

Media: Ensure media IDs are type int in bulk editing.

Cast all array values to integers using array_map so functions like wp_delete_attachment receiving the expected variable type.

Props eherman24, joedolson.
Fixes #56170.

File:
1 edited

Legend:

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

    r55178 r55183  
    220220                $post_ids = explode( ',', $_REQUEST['ids'] );
    221221        }
     222        $post_ids = array_map( 'intval', (array) $post_ids );
    222223
    223224        $location = 'upload.php';
     
    242243                                break;
    243244                        }
    244                         foreach ( (array) $post_ids as $post_id ) {
     245                        foreach ( $post_ids as $post_id ) {
    245246                                if ( ! current_user_can( 'delete_post', $post_id ) ) {
    246247                                        wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
     
    263264                                break;
    264265                        }
    265                         foreach ( (array) $post_ids as $post_id ) {
     266                        foreach ( $post_ids as $post_id ) {
    266267                                if ( ! current_user_can( 'delete_post', $post_id ) ) {
    267268                                        wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) );
     
    278279                                break;
    279280                        }
    280                         foreach ( (array) $post_ids as $post_id_del ) {
     281                        foreach ( $post_ids as $post_id_del ) {
    281282                                if ( ! current_user_can( 'delete_post', $post_id_del ) ) {
    282283                                        wp_die( __( 'Sorry, you are not allowed to delete this item.' ) );
Note: See TracChangeset for help on using the changeset viewer.