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

Update test-optimization.php #1428

Merged

Conversation

nextend
Copy link
Contributor

@nextend nextend commented Aug 2, 2024

Amends #1317

See WordPress/gutenberg#62770

WordPress/gutenberg#62770 (comment):

@westonruter I think the missing piece is to call ob_end_flush(); before calling ob_get_clean();.

On line 91, a new output buffer is created. This output buffer is necessary as it allows you to access the output in the same way the PHP runtime does when outputting the default output buffer.

In the original code, the following happened:

  • System [1] output buffer <- This will be sent to the browser.

In the new code:

  • System [1] output buffer <- This will be sent to the browser.

    • Line 91 -> [2] output buffer

      • od_buffer_output -> [3] output buffer
      • ob_end_flush -> Output buffer [3] is closed -> ob callback gets called -> Result of the callback is flushed into [2] buffer
    • Now we can access the real output with ob_get_clean, which gives us the content of the [2] buffer (and then discards the output).

Copy link

github-actions bot commented Aug 2, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @nextend.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: nextend.


To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter westonruter merged commit 3235f3b into WordPress:update/ob-handling Aug 6, 2024
11 checks passed
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.

2 participants