1 | Index: src/js/_enqueues/vendor/plupload/handlers.js |
---|
2 | =================================================================== |
---|
3 | --- src/js/_enqueues/vendor/plupload/handlers.js (revision 46194) |
---|
4 | +++ src/js/_enqueues/vendor/plupload/handlers.js (working copy) |
---|
5 | @@ -279,7 +279,7 @@ |
---|
6 | } |
---|
7 | } |
---|
8 | |
---|
9 | -function uploadError( fileObj, errorCode, message, up ) { |
---|
10 | +function uploadError( fileObj, errorCode, message, responseHeaders, up ) { |
---|
11 | var hundredmb = 100 * 1024 * 1024, max; |
---|
12 | |
---|
13 | switch ( errorCode ) { |
---|
14 | @@ -315,7 +315,15 @@ |
---|
15 | |
---|
16 | break; |
---|
17 | case plupload.HTTP_ERROR: |
---|
18 | - wpQueueError( pluploadL10n.http_error ); |
---|
19 | + message = pluploadL10n.http_error; |
---|
20 | + |
---|
21 | + var myRegexp = /x-wp-lasterror-message: (.*)/gm; |
---|
22 | + var match = myRegexp.exec( responseHeaders ); |
---|
23 | + if( match[1] ) { |
---|
24 | + message += ' ' + match[1]; |
---|
25 | + } |
---|
26 | + |
---|
27 | + wpQueueError(message); |
---|
28 | break; |
---|
29 | case plupload.INIT_ERROR: |
---|
30 | jQuery( '.media-upload-form' ).addClass( 'html-uploader' ); |
---|
31 | @@ -578,7 +586,7 @@ |
---|
32 | return; |
---|
33 | } |
---|
34 | |
---|
35 | - uploadError( error.file, error.code, error.message, up ); |
---|
36 | + uploadError( error.file, error.code, error.message, error.responseHeaders, up); |
---|
37 | up.refresh(); |
---|
38 | }); |
---|
39 | |
---|
40 | Index: src/wp-includes/functions.php |
---|
41 | =================================================================== |
---|
42 | --- src/wp-includes/functions.php (revision 46194) |
---|
43 | +++ src/wp-includes/functions.php (working copy) |
---|
44 | @@ -3255,6 +3255,15 @@ |
---|
45 | nocache_headers(); |
---|
46 | } |
---|
47 | |
---|
48 | + if( isset( $parsed_args['last_error_message'] ) && $parsed_args['last_error_message']) { |
---|
49 | + $sent_header = ( WP_DEBUG || ( is_user_logged_in() ) ); |
---|
50 | + $sent_header = apply_filters( 'wp_die_handler_sent_error_header', $sent_header ); |
---|
51 | + |
---|
52 | + if( $sent_header ) { |
---|
53 | + header( 'X-WP-lasterror-message: '.$parsed_args['last_error_message'] ); |
---|
54 | + } |
---|
55 | + } |
---|
56 | + |
---|
57 | $text_direction = $parsed_args['text_direction']; |
---|
58 | if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) { |
---|
59 | $dir_attr = get_language_attributes(); |
---|
60 | @@ -3660,6 +3669,11 @@ |
---|
61 | |
---|
62 | $args = wp_parse_args( $args, $defaults ); |
---|
63 | |
---|
64 | + // Early |
---|
65 | + if( $message instanceof WP_Error && isset( $message->error_data['internal_server_error']['error']['message'] ) ) { |
---|
66 | + $args['last_error_message'] = $message->error_data['internal_server_error']['error']['message']; |
---|
67 | + } |
---|
68 | + |
---|
69 | if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { |
---|
70 | if ( ! empty( $message->errors ) ) { |
---|
71 | $errors = array(); |
---|
72 | @@ -3684,6 +3698,10 @@ |
---|
73 | $title = $errors[0]['data']['title']; |
---|
74 | } |
---|
75 | |
---|
76 | + if( isset( $errors[0][0] ) ) { |
---|
77 | + $args['last_error'] = array_values( $errors[0][0] ); |
---|
78 | + } |
---|
79 | + |
---|
80 | unset( $errors[0] ); |
---|
81 | $args['additional_errors'] = array_values( $errors ); |
---|
82 | } else { |
---|