From 379bec8ea6d9c90dd21f7089542bc91978f49d6b Mon Sep 17 00:00:00 2001 From: joedolson Date: Wed, 1 Feb 2023 22:17:15 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@55183 git-svn-id: http://core.svn.wordpress.org/trunk@54716 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/upload.php | 7 ++++--- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 87078001c4..1790ab281e 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -219,6 +219,7 @@ if ( $doaction ) { } elseif ( isset( $_REQUEST['ids'] ) ) { $post_ids = explode( ',', $_REQUEST['ids'] ); } + $post_ids = array_map( 'intval', (array) $post_ids ); $location = 'upload.php'; $referer = wp_get_referer(); @@ -241,7 +242,7 @@ if ( $doaction ) { if ( empty( $post_ids ) ) { break; } - foreach ( (array) $post_ids as $post_id ) { + foreach ( $post_ids as $post_id ) { if ( ! current_user_can( 'delete_post', $post_id ) ) { wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); } @@ -262,7 +263,7 @@ if ( $doaction ) { if ( empty( $post_ids ) ) { break; } - foreach ( (array) $post_ids as $post_id ) { + foreach ( $post_ids as $post_id ) { if ( ! current_user_can( 'delete_post', $post_id ) ) { wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); } @@ -277,7 +278,7 @@ if ( $doaction ) { if ( empty( $post_ids ) ) { break; } - foreach ( (array) $post_ids as $post_id_del ) { + foreach ( $post_ids as $post_id_del ) { if ( ! current_user_can( 'delete_post', $post_id_del ) ) { wp_die( __( 'Sorry, you are not allowed to delete this item.' ) ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 9114c48e54..fa025de270 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55182'; +$wp_version = '6.2-alpha-55183'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.