Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare AMP response at shutdown instead of output buffer callback #931

Merged
merged 2 commits into from Feb 5, 2018

Conversation

Projects
None yet
2 participants
@westonruter
Copy link
Member

commented Feb 5, 2018

This will make it easier to debug things since printing can be done in shutdown function but cannot in output buffer callback.

Furthermore, this prevents a fatal error if print_r() is attempted in the output buffer callback:

PHP Fatal error: print_r(): Cannot use output buffering in output buffering display handlers in .../wp-content/plugins/amp/includes/class-amp-theme-support.php on line 863

@westonruter westonruter added this to the v0.7 milestone Feb 5, 2018

@westonruter westonruter requested a review from ThierryA Feb 5, 2018

* @see AMP_Theme_Support::start_output_buffering()
*/
public static function finish_output_buffering() {
$output = ob_get_clean();

This comment has been minimized.

Copy link
@ThierryA

ThierryA Feb 5, 2018

Collaborator

I would advise to avoid storing the output in a variable unless necessary, especially in the context of the output buffer. For instance the memory goes from 3018376 to 3006088 on my local install by moving ob_get_clean() to self::prepare_response( ob_get_clean() );.

@ThierryA ThierryA merged commit c293486 into develop Feb 5, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@westonruter westonruter deleted the improve/output-buffering branch Feb 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.