Skip to content

Commit 203d301

Browse files
committed
Call error_get_last() prior to calling sanitizers to ensure fatal error is not masked (#5375)
1 parent 29cebde commit 203d301

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

includes/class-amp-theme-support.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,7 @@ public static function filter_customize_partial_render( $partial ) {
19311931
*/
19321932
public static function prepare_response( $response, $args = [] ) {
19331933
global $content_width;
1934+
$last_error = error_get_last();
19341935

19351936
if ( isset( $args['validation_error_callback'] ) ) {
19361937
_doing_it_wrong( __METHOD__, 'Do not supply validation_error_callback arg.', '1.0' );
@@ -2098,11 +2099,10 @@ public static function prepare_response( $response, $args = [] ) {
20982099
if ( AMP_Validation_Manager::$is_validate_request ) {
20992100
status_header( 200 );
21002101
header( 'Content-Type: application/json; charset=utf-8' );
2101-
$data = [
2102+
$data = [
21022103
'http_status_code' => $status_code,
21032104
'php_fatal_error' => false,
21042105
];
2105-
$last_error = error_get_last();
21062106
if ( $last_error && in_array( $last_error['type'], [ E_ERROR, E_RECOVERABLE_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_PARSE ], true ) ) {
21072107
$data['php_fatal_error'] = $last_error;
21082108
}

0 commit comments

Comments
 (0)