Changeset 42761
- Timestamp:
- 02/27/2018 02:30:46 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r42720 r42761 3693 3693 $status['errorMessage'] = $skin->result->get_error_message(); 3694 3694 wp_send_json_error( $status ); 3695 } elseif ( $skin->get_errors()-> get_error_code() ) {3695 } elseif ( $skin->get_errors()->has_errors() ) { 3696 3696 $status['errorMessage'] = $skin->get_error_messages(); 3697 3697 wp_send_json_error( $status ); … … 3703 3703 3704 3704 // Pass through the error from WP_Filesystem if one was raised. 3705 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {3705 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 3706 3706 $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); 3707 3707 } … … 3806 3806 $status['errorMessage'] = $skin->result->get_error_message(); 3807 3807 wp_send_json_error( $status ); 3808 } elseif ( $skin->get_errors()-> get_error_code() ) {3808 } elseif ( $skin->get_errors()->has_errors() ) { 3809 3809 $status['errorMessage'] = $skin->get_error_messages(); 3810 3810 wp_send_json_error( $status ); … … 3830 3830 3831 3831 // Pass through the error from WP_Filesystem if one was raised. 3832 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {3832 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 3833 3833 $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); 3834 3834 } … … 3892 3892 3893 3893 // Pass through the error from WP_Filesystem if one was raised. 3894 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {3894 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 3895 3895 $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); 3896 3896 } … … 3981 3981 $status['errorMessage'] = $skin->result->get_error_message(); 3982 3982 wp_send_json_error( $status ); 3983 } elseif ( $skin->get_errors()-> get_error_code() ) {3983 } elseif ( $skin->get_errors()->has_errors() ) { 3984 3984 $status['errorMessage'] = $skin->get_error_messages(); 3985 3985 wp_send_json_error( $status ); … … 3991 3991 3992 3992 // Pass through the error from WP_Filesystem if one was raised. 3993 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {3993 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 3994 3994 $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); 3995 3995 } … … 4082 4082 $status['errorMessage'] = $skin->result->get_error_message(); 4083 4083 wp_send_json_error( $status ); 4084 } elseif ( $skin->get_errors()-> get_error_code() ) {4084 } elseif ( $skin->get_errors()->has_errors() ) { 4085 4085 $status['errorMessage'] = $skin->get_error_messages(); 4086 4086 wp_send_json_error( $status ); … … 4116 4116 4117 4117 // Pass through the error from WP_Filesystem if one was raised. 4118 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {4118 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 4119 4119 $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); 4120 4120 } … … 4183 4183 4184 4184 // Pass through the error from WP_Filesystem if one was raised. 4185 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {4185 if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 4186 4186 $status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() ); 4187 4187 } -
trunk/src/wp-admin/includes/class-wp-ajax-upgrader-skin.php
r42343 r42761 62 62 63 63 foreach ( $this->errors->get_error_codes() as $error_code ) { 64 if ( $this->errors->get_error_data( $error_code ) && is_string( $this->errors->get_error_data( $error_code ) ) ) { 65 $messages[] = $this->errors->get_error_message( $error_code ) . ' ' . esc_html( strip_tags( $this->errors->get_error_data( $error_code ) ) ); 64 $error_data = $this->errors->get_error_data( $error_code ); 65 66 if ( $error_data && is_string( $error_data ) ) { 67 $messages[] = $this->errors->get_error_message( $error_code ) . ' ' . esc_html( strip_tags( $error_data ) ); 66 68 } else { 67 69 $messages[] = $this->errors->get_error_message( $error_code ); -
trunk/src/wp-admin/includes/class-wp-upgrader-skin.php
r42343 r42761 128 128 if ( is_string( $errors ) ) { 129 129 $this->feedback( $errors ); 130 } elseif ( is_wp_error( $errors ) && $errors-> get_error_code() ) {130 } elseif ( is_wp_error( $errors ) && $errors->has_errors() ) { 131 131 foreach ( $errors->get_error_messages() as $message ) { 132 132 if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) { -
trunk/src/wp-admin/includes/class-wp-upgrader.php
r42745 r42761 192 192 if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) { 193 193 $error = true; 194 if ( is_object( $wp_filesystem ) && $wp_filesystem->errors-> get_error_code() ) {194 if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_errors() ) { 195 195 $error = $wp_filesystem->errors; 196 196 } … … 204 204 } 205 205 206 if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {206 if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 207 207 return new WP_Error( 'fs_error', $this->strings['fs_error'], $wp_filesystem->errors ); 208 208 } -
trunk/src/wp-admin/includes/file.php
r42719 r42761 1461 1461 } 1462 1462 1463 if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {1463 if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 1464 1464 return false; 1465 1465 } -
trunk/src/wp-admin/includes/plugin.php
r42710 r42761 866 866 } 867 867 868 if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {868 if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 869 869 return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors ); 870 870 } -
trunk/src/wp-admin/includes/schema.php
r42343 r42761 981 981 } 982 982 983 if ( $errors-> get_error_code() ) {983 if ( $errors->has_errors() ) { 984 984 return $errors; 985 985 } -
trunk/src/wp-admin/includes/theme.php
r42711 r42761 61 61 } 62 62 63 if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors-> get_error_code() ) {63 if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { 64 64 return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors ); 65 65 } -
trunk/src/wp-admin/includes/user.php
r42343 r42761 208 208 do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) ); 209 209 210 if ( $errors-> get_error_codes() ) {210 if ( $errors->has_errors() ) { 211 211 return $errors; 212 212 } -
trunk/src/wp-admin/network/user-new.php
r42343 r42761 45 45 46 46 $user_details = wpmu_validate_user_signup( $user['username'], $user['email'] ); 47 if ( is_wp_error( $user_details['errors'] ) && ! empty( $user_details['errors']->errors) ) {47 if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) { 48 48 $add_user_errors = $user_details['errors']; 49 49 } else { -
trunk/src/wp-admin/update-core.php
r42631 r42761 500 500 } 501 501 502 if ( $wp_filesystem->errors-> get_error_code() ) {502 if ( $wp_filesystem->errors->has_errors() ) { 503 503 foreach ( $wp_filesystem->errors->get_error_messages() as $message ) { 504 504 show_message( $message ); -
trunk/src/wp-admin/user-new.php
r42719 r42761 161 161 $new_user_email = wp_unslash( $_REQUEST['email'] ); 162 162 $user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email ); 163 if ( is_wp_error( $user_details['errors'] ) && ! empty( $user_details['errors']->errors) ) {163 if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) { 164 164 $add_user_errors = $user_details['errors']; 165 165 } else { -
trunk/src/wp-includes/class-wp-customize-manager.php
r42719 r42761 2303 2303 /** This filter is documented in wp-includes/class-wp-customize-setting.php */ 2304 2304 $late_validity = apply_filters( "customize_validate_{$setting->id}", new WP_Error(), $unsanitized_value, $setting ); 2305 if ( ! empty( $late_validity->errors) ) {2305 if ( $late_validity->has_errors() ) { 2306 2306 $validity = $late_validity; 2307 2307 } -
trunk/src/wp-includes/class-wp-customize-setting.php
r42747 r42761 595 595 $validity = apply_filters( "customize_validate_{$this->id}", $validity, $value, $this ); 596 596 597 if ( is_wp_error( $validity ) && empty( $validity->errors) ) {597 if ( is_wp_error( $validity ) && ! $validity->has_errors() ) { 598 598 $validity = true; 599 599 } -
trunk/src/wp-includes/class-wp-error.php
r42343 r42761 72 72 */ 73 73 public function get_error_codes() { 74 if ( empty( $this->errors) ) {74 if ( ! $this->has_errors() ) { 75 75 return array(); 76 76 } … … 163 163 164 164 /** 165 * Verify if the instance contains errors. 166 * 167 * @since 5.0.0 168 * 169 * @return bool 170 */ 171 public function has_errors() { 172 if ( ! empty( $this->errors ) ) { 173 return true; 174 } 175 return false; 176 } 177 178 /** 165 179 * Add an error or append additional message to an existing error. 166 180 * -
trunk/src/wp-includes/customize/class-wp-customize-custom-css-setting.php
r42343 r42761 162 162 } 163 163 164 if ( empty( $validity->errors) ) {164 if ( ! $validity->has_errors() ) { 165 165 $validity = parent::validate( $css ); 166 166 } -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r42343 r42761 471 471 $ret = wpmu_validate_user_signup( $user->user_login, $user->user_email ); 472 472 473 if ( is_wp_error( $ret['errors'] ) && ! empty( $ret['errors']->errors) ) {473 if ( is_wp_error( $ret['errors'] ) && $ret['errors']->has_errors() ) { 474 474 $error = new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) ); 475 475 foreach ( $ret['errors']->errors as $code => $messages ) { -
trunk/src/wp-includes/user.php
r42710 r42761 2470 2470 $errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email ); 2471 2471 2472 if ( $errors-> get_error_code() ) {2472 if ( $errors->has_errors() ) { 2473 2473 return $errors; 2474 2474 } -
trunk/src/wp-login.php
r42406 r42761 54 54 $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes ); 55 55 56 if ( $shake_error_codes && $wp_error-> get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) {56 if ( $shake_error_codes && $wp_error->has_errors() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) { 57 57 add_action( 'login_head', 'wp_shake_js', 12 ); 58 58 } … … 209 209 } 210 210 211 if ( $wp_error-> get_error_code() ) {211 if ( $wp_error->has_errors() ) { 212 212 $errors = ''; 213 213 $messages = ''; … … 342 342 do_action( 'lostpassword_post', $errors ); 343 343 344 if ( $errors-> get_error_code() ) {344 if ( $errors->has_errors() ) { 345 345 return $errors; 346 346 } … … 688 688 do_action( 'validate_password_reset', $errors, $user ); 689 689 690 if ( ( ! $errors-> get_error_code() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {690 if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) { 691 691 reset_password( $user, $_POST['pass1'] ); 692 692 setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true ); … … 974 974 975 975 if ( $interim_login ) { 976 if ( ! $errors-> get_error_code() ) {976 if ( ! $errors->has_errors() ) { 977 977 $errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' ); 978 978 } … … 1016 1016 $rememberme = ! empty( $_POST['rememberme'] ); 1017 1017 1018 if ( ! empty( $errors->errors) ) {1018 if ( $errors->has_errors() ) { 1019 1019 $aria_describedby_error = ' aria-describedby="login_error"'; 1020 1020 } else { -
trunk/src/wp-signup.php
r42343 r42761 324 324 echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>'; 325 325 326 if ( $errors-> get_error_code() ) {326 if ( $errors->has_errors() ) { 327 327 echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>'; 328 328 } … … 390 390 $errors = $result['errors']; 391 391 392 if ( $errors-> get_error_code() ) {392 if ( $errors->has_errors() ) { 393 393 signup_another_blog( $blogname, $blog_title, $errors ); 394 394 return false; … … 605 605 $errors = $result['errors']; 606 606 607 if ( $errors-> get_error_code() ) {607 if ( $errors->has_errors() ) { 608 608 signup_user( $user_name, $user_email, $errors ); 609 609 return false; … … 730 730 $user_errors = $user_result['errors']; 731 731 732 if ( $user_errors-> get_error_code() ) {732 if ( $user_errors->has_errors() ) { 733 733 signup_user( $user_name, $user_email, $user_errors ); 734 734 return false; … … 742 742 $errors = $result['errors']; 743 743 744 if ( $errors-> get_error_code() ) {744 if ( $errors->has_errors() ) { 745 745 signup_blog( $user_name, $user_email, $blogname, $blog_title, $errors ); 746 746 return false; -
trunk/tests/phpunit/tests/general/wpError.php
r42646 r42761 377 377 378 378 /** 379 * @covers ::has_errors() 380 */ 381 public function test_has_errors_with_no_errors_returns_false() { 382 $this->assertFalse( $this->WP_Error->has_errors() ); 383 } 384 385 /** 386 * @covers ::has_errors() 387 */ 388 public function test_has_errors_with_errors_returns_true() { 389 $this->WP_Error->add( 'code', 'message', 'data' ); 390 $this->assertTrue( $this->WP_Error->has_errors() ); 391 } 392 393 /** 379 394 * @covers ::add() 380 395 */
Note: See TracChangeset
for help on using the changeset viewer.