Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/private/AppFramework/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,10 @@ public static function main(
$io->setOutput($output);
}
}

if ($response->getFlushEarly()) {
ob_flush();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ob_flush();
while (ob_get_level() > 0) {
ob_end_flush();
}

I would go with this snippet to ensure all is flushed

flush();
}
}
}
22 changes: 22 additions & 0 deletions lib/public/AppFramework/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Response {

/** @var bool */
private $throttled = false;
private bool $flushEarly = true;
/** @var array */
private $throttleMetadata = [];

Expand Down Expand Up @@ -412,4 +413,25 @@ public function getThrottleMetadata() {
public function isThrottled() {
return $this->throttled;
}

/**
* Request the response should be flushed to the connected client immediately
*
* @since 34.0.0
*/
public function setFlushEarly(bool $flushEarly): void {
$this->flushEarly = $flushEarly;
}
Comment on lines +422 to +424
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the default is to flush early, maybe this is more explicit:

Suggested change
public function setFlushEarly(bool $flushEarly): void {
$this->flushEarly = $flushEarly;
}
public function dontFlushEarly(): void {
$this->flushEarly = false;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the default is to flush early

That's TBD. It could be problematic in some cases, but in theory it could break things unintentionally, or at least be a behaviour change


/**
* Whether the response should be flushed to the connected client immediately
*
* If not, the response will wait for async actions, e.g. HTTP requests from
* IClientService, to be finished before returning.
*
* @since 34.0.0
*/
public function getFlushEarly(): bool {
return $this->flushEarly;
}
}
Loading