Skip to content

Commit

Permalink
Media: Ensure media IDs are type int in bulk editing.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joedolson committed Feb 1, 2023
1 parent e8bd962 commit 379bec8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions wp-admin/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
} elseif ( isset( $_REQUEST['ids'] ) ) {
$post_ids = explode( ',', $_REQUEST['ids'] );
}
$post_ids = array_map( 'intval', (array) $post_ids );

$location = 'upload.php';
$referer = wp_get_referer();
Expand All @@ -241,7 +242,7 @@
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.' ) );
}
Expand All @@ -262,7 +263,7 @@
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.' ) );
}
Expand All @@ -277,7 +278,7 @@
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.' ) );
}
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 379bec8

Please sign in to comment.