File Editor: Increase robustness of fatal error checking when saving PHP file edits.

* Increase PHP execution time limit prior to issuing loopback requests where are themselves given timeouts to ensure PHP file can be reverted.
* Output scrape messages on success and failure so that absence of either can also be flagged as an error condition.
* Forward browser's HTTP Basic Auth credentials in loopback requests to admin and home URL.
* Display more helpful message when loopback request fails.

Amends [41721].
See #21622.
Fixes #42102.


git-svn-id: https://develop.svn.wordpress.org/trunk@41805 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter
2017-10-10 05:26:53 +00:00
parent 55f2dac880
commit 5deddd9c62
4 changed files with 71 additions and 25 deletions
+9 -9
View File
@@ -1126,11 +1126,12 @@ function wp_start_scraping_edited_file_errors() {
$nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] );
if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) {
echo "###### begin_scraped_error:$key ######";
echo "###### wp_scraping_result_start:$key ######";
echo wp_json_encode( array(
'code' => 'scrape_nonce_failure',
'message' => __( 'Scrape nonce check failed. Please try again.' ),
) );
echo "###### wp_scraping_result_end:$key ######";
die();
}
register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key );
@@ -1145,13 +1146,12 @@ function wp_start_scraping_edited_file_errors() {
*/
function wp_finalize_scraping_edited_file_errors( $scrape_key ) {
$error = error_get_last();
if ( empty( $error ) ) {
return;
echo "\n###### wp_scraping_result_start:$scrape_key ######\n";
if ( ! empty( $error ) && in_array( $error['type'], array( E_CORE_ERROR, E_COMPILE_ERROR, E_ERROR, E_PARSE, E_USER_ERROR, E_RECOVERABLE_ERROR ), true ) ) {
$error = str_replace( ABSPATH, '', $error );
echo wp_json_encode( $error );
} else {
echo wp_json_encode( true );
}
if ( ! in_array( $error['type'], array( E_CORE_ERROR, E_COMPILE_ERROR, E_ERROR, E_PARSE, E_USER_ERROR, E_RECOVERABLE_ERROR ), true ) ) {
return;
}
$error = str_replace( ABSPATH, '', $error );
echo "###### begin_scraped_error:$scrape_key ######";
echo wp_json_encode( $error );
echo "\n###### wp_scraping_result_end:$scrape_key ######\n";
}