Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WebProfilerBundle] add debugbar on StreamedResponse #58789

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

Open
wants to merge 4 commits into
base: 7.3
Choose a base branch
Loading
from

Conversation

damienfern
Copy link
Contributor

@damienfern damienfern commented Nov 6, 2024

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #57288
License MIT


class MockedStreamedResponse extends StreamedResponse
{
public function getContent(): string|false
Copy link
Member

Choose a reason for hiding this comment

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

I would not override the getContent method of StreamedResponse for that, as it means this MockedStreamedResponse does not actually behave like a StreamedResponse (in which you cannot call getContent to get the actual content), which would potentially hide bugs in tests.

Instead, I would suggest writing a separate test covering the injection of the toolbar in a streamed response, which would perform this output buffering in the test (using $response->sendContent()).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right and indeed I missed a bug on StreamedResponse here.

Let me know if it's ok for you.

@damienfern damienfern force-pushed the streamResponse_webdebugToolbar branch 2 times, most recently from 9a631e3 to 642ebed Compare November 7, 2024 16:59
@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@OskarStark OskarStark changed the title [WebProfilerBundle] add debugbar on StreamedResponse [WebProfilerBundle] add debugbar on `StreamedResponse´ Nov 21, 2024
@damienfern damienfern force-pushed the streamResponse_webdebugToolbar branch from ac59dd8 to 5f7393b Compare January 24, 2025 10:30
@damienfern damienfern force-pushed the streamResponse_webdebugToolbar branch from 5f7393b to 6f0f764 Compare January 24, 2025 10:31
@damienfern damienfern force-pushed the streamResponse_webdebugToolbar branch from 7787e2a to 677f95c Compare January 24, 2025 10:38
@damienfern damienfern requested a review from stof January 24, 2025 10:47
@OskarStark OskarStark changed the title [WebProfilerBundle] add debugbar on `StreamedResponse´ [WebProfilerBundle] add debugbar on StreamedResponse Jan 24, 2025
@@ -5,6 +5,7 @@ CHANGELOG
---

* Add `ajax_replace` option for replacing toolbar on AJAX requests
* Show debug bar when using a streamed response
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Show debug bar when using a streamed response
* Add support for streamed responses in the debug toolbar

return $buffer;
}, 8); // length of '</body>'

($callback)();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
($callback)();
$callback();

$response = new StreamedResponse($this->createCallbackFromContent($content));

$m->invoke($listener, $response, Request::create('/'), ['csp_script_nonce' => 'scripto', 'csp_style_nonce' => 'stylo']);
$this->assertEquals($expected, $this->getContentFromStreamedResponse($response));
Copy link
Member

Choose a reason for hiding this comment

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

Prefer using assertSame() wherever possible in the whole test class

$this->assertEquals($expected, $this->getContentFromStreamedResponse($response));
}

public static function getInjectToolbarTests()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public static function getInjectToolbarTests()
public static function provideInjectedToolbarHtml()

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

Successfully merging this pull request may close these issues.

Web developer toolbar incompatible with streaming
5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.