From 7d8a053aebddc1df6722ebb7f0c253e299c9837b Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 15 May 2014 15:24:21 +0000 Subject: [PATCH] Eliminate use of `extract()` in `WP_Ajax_Response::add()`. Just set most of the properties to variables to avoid interpolation churn. See #22400. git-svn-id: https://develop.svn.wordpress.org/trunk@28430 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-ajax-response.php | 40 +++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/wp-includes/class-wp-ajax-response.php b/src/wp-includes/class-wp-ajax-response.php index 24eb687f12..0a8016c980 100644 --- a/src/wp-includes/class-wp-ajax-response.php +++ b/src/wp-includes/class-wp-ajax-response.php @@ -61,33 +61,40 @@ class WP_Ajax_Response { ); $r = wp_parse_args( $args, $defaults ); - extract( $r, EXTR_SKIP ); - $position = preg_replace( '/[^a-z0-9:_-]/i', '', $position ); - if ( is_wp_error($id) ) { + $position = preg_replace( '/[^a-z0-9:_-]/i', '', $r['position'] ); + $id = $r['id']; + $what = $r['what']; + $action = $r['action']; + $old_id = $r['old_id']; + $data = $r['data']; + + if ( is_wp_error( $id ) ) { $data = $id; $id = 0; } $response = ''; - if ( is_wp_error($data) ) { + if ( is_wp_error( $data ) ) { foreach ( (array) $data->get_error_codes() as $code ) { - $response .= "get_error_message($code) . "]]>"; - if ( !$error_data = $data->get_error_data($code) ) + $response .= "get_error_message( $code ) . "]]>"; + if ( ! $error_data = $data->get_error_data( $code ) ) { continue; + } $class = ''; - if ( is_object($error_data) ) { - $class = ' class="' . get_class($error_data) . '"'; - $error_data = get_object_vars($error_data); + if ( is_object( $error_data ) ) { + $class = ' class="' . get_class( $error_data ) . '"'; + $error_data = get_object_vars( $error_data ); } $response .= ""; - if ( is_scalar($error_data) ) { + if ( is_scalar( $error_data ) ) { $response .= ""; - } elseif ( is_array($error_data) ) { - foreach ( $error_data as $k => $v ) + } elseif ( is_array( $error_data ) ) { + foreach ( $error_data as $k => $v ) { $response .= "<$k>"; + } } $response .= ""; @@ -97,15 +104,16 @@ class WP_Ajax_Response { } $s = ''; - if ( is_array($supplemental) ) { - foreach ( $supplemental as $k => $v ) + if ( is_array( $r['supplemental'] ) ) { + foreach ( $r['supplemental'] as $k => $v ) { $s .= "<$k>"; + } $s = "$s"; } - if ( false === $action ) + if ( false === $action ) { $action = $_POST['action']; - + } $x = ''; $x .= ""; // The action attribute in the xml output is formatted like a nonce action $x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>";