-
Notifications
You must be signed in to change notification settings - Fork 382
Turn off display_errors during the post-processing phase (sanitization) #1915
Copy link
Copy link
Closed
Labels
Description
A user reported a two fatal errors showing up in the log:
[28-Feb-2019 17:51:38 UTC] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 72 bytes) in .../wp-content/plugins/amp/vendor/sabberworm/php-css-parser/lib/Sabberworm/CSS/Parser.php on line 784
[28-Feb-2019 17:51:38 UTC] PHP Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
The second error is a symptom of the first (for that see #1914). The site has display_errors turned on and so the printing of the first error is causing the second error. To prevent the second error from happening, we need to turn off display_errors during post-processing.
This actually identifies an improvement to be made in the plugin: we need to turn off display_errors during post-processing so that this doesn't happen. This should be done in the AMP_Theme_Support::prepare_response() method:
amp-wp/includes/class-amp-theme-support.php
Lines 1616 to 1632 in 616d7a3
| public static function prepare_response( $response, $args = array() ) { | |
| global $content_width; | |
| $prepare_response_start = microtime( true ); | |
| if ( isset( $args['validation_error_callback'] ) ) { | |
| _doing_it_wrong( __METHOD__, 'Do not supply validation_error_callback arg.', '1.0' ); | |
| unset( $args['validation_error_callback'] ); | |
| } | |
| /* | |
| * Check if the response starts with HTML markup. | |
| * Without this check, JSON responses will be erroneously corrupted, | |
| * being wrapped in HTML documents. | |
| */ | |
| if ( '<' !== substr( ltrim( $response ), 0, 1 ) ) { | |
| return $response; | |
| } |
Reactions are currently unavailable