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

Fix output buffer fatal error due to not properly handling class method output callbacks #1453

Merged
merged 2 commits into from
Sep 22, 2018

Conversation

westonruter
Copy link
Member

When activating the all-in-one-seo-pack plugin, an error shows up in the error log when validating a URL:

PHP Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers

The underlying code in the plugin that causes the problem is the adding of the All_in_One_SEO_Pack ::output_callback_for_title() method as an output buffer callback in:

https://github.com/semperfiwebdesign/all-in-one-seo-pack/blob/982cbb6a6ba183cf538d86b858273505a417720f/aioseop_class.php#L3496

The AMP plugin is supposed to prevent this error from happening via the AMP_Validation_Manager::can_output_buffer() method. It turns out there was a flaw in the logic being used to convert a function on the call stack into the format expected by ob_list_handlers(). In particular, it was not handling the case where an output callback was a class method. The issue is fixed by properly detecting when a call stack entry is for a class method.

This pull request also improves error message shown when a validate_url call fails. Instead of showing an error code like response_comment_absent it will now show a full message explaining what is going on. This change also adds WSOD (whitescreen of death detection) as a more specific error case for when the JSON comment is absent:

image

@westonruter westonruter added this to the v1.0 milestone Sep 22, 2018
Copy link
Member

@amedina amedina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it.

@westonruter westonruter merged commit 220800d into develop Sep 22, 2018
@westonruter westonruter deleted the fix/can-output-buffer-method-callbacks branch September 22, 2018 22:16
@postphotos
Copy link
Contributor

This one was fun to find. 🐞 Thanks for digging in, @westonruter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants