From 8d9b2cd2b3603bc2963765cbcda11cd163e0aaf2 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 15 Nov 2010 06:38:10 +0000 Subject: [PATCH] Properly check, initialize, or cast a number of variables. props ChenHui. see #14642. git-svn-id: https://develop.svn.wordpress.org/trunk@16377 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit.php | 11 ++++++----- wp-admin/includes/image-edit.php | 4 ++-- wp-admin/includes/user.php | 4 ++-- wp-includes/functions.php | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/wp-admin/edit.php b/wp-admin/edit.php index dae0333465..6fea2dc9b8 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -13,12 +13,13 @@ $wp_list_table = get_list_table('WP_Posts_List_Table'); $wp_list_table->check_permissions(); // Back-compat for viewing comments of an entry -if ( $_redirect = intval( max( @$_REQUEST['p'], @$_REQUEST['attachment_id'], @$_REQUEST['page_id'] ) ) ) { - wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) ); - exit; -} else { - unset( $_redirect ); +foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) { + if ( ! empty( $_REQUEST[ $_redirect ] ) ) { + wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) ); + exit; + } } +unset( $_redirect ); // Handle bulk actions $doaction = $wp_list_table->current_action(); diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php index 3e1a6b05a0..03e7144af0 100644 --- a/wp-admin/includes/image-edit.php +++ b/wp-admin/includes/image-edit.php @@ -422,7 +422,7 @@ function wp_restore_image($post_id) { $file = get_attached_file($post_id); $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); $restored = false; - $msg = ''; + $msg = new stdClass; if ( !is_array($backup_sizes) ) { $msg->error = __('Cannot load image metadata.'); @@ -493,7 +493,7 @@ function wp_restore_image($post_id) { } function wp_save_image($post_id) { - $return = ''; + $return = new stdClass; $success = $delete = $scaled = $nocrop = false; $post = get_post($post_id); @ini_set('memory_limit', '256M'); diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index 6790cfe0e9..4015a02adc 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -55,14 +55,14 @@ function add_user() { */ function edit_user( $user_id = 0 ) { global $wp_roles, $wpdb; - if ( $user_id != 0 ) { + $user = new WP_User( $user_id ); + if ( $user_id ) { $update = true; $user->ID = (int) $user_id; $userdata = get_userdata( $user_id ); $user->user_login = $wpdb->escape( $userdata->user_login ); } else { $update = false; - $user = ''; } if ( !$update && isset( $_POST['user_login'] ) ) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 632fee00f6..b01831d9bf 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -4232,7 +4232,7 @@ function get_file_data( $file, $default_headers, $context = '' ) { foreach( $extra_headers as $key=>$value ) { $extra_headers[$key] = $key; } - $all_headers = array_merge($extra_headers, $default_headers); + $all_headers = array_merge( $extra_headers, (array) $default_headers ); } else { $all_headers = $default_headers; }