@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

If HTTP response headers are already sent, don't fiddle with "zlib.output_compression"

Summary:
We write some synthetic HTTP responses inside unit tests. Some responses have an indirect side effect of adjusting "zlib.output_compression", but this adjustment fails if headers have already been output. From a CLI context, headers appear to count as already-output after we write anything to stdout:

```
<?php

echo headers_sent() ? "Y" : "N";
echo "\n";
echo headers_sent() ? "Y" : "N";
echo "\n";
```

This script prints "N", then "Y".

Recently, the default severity of warnings was increased in libphutil; this has been a long-standing warning but now causes test failures.

This behavior is sort of silly but the whole thing is kind of moot anyway. Just skip it if "headers_sent()" is true.

Test Plan: Ran "arc unit --everything", got clean results.

Differential Revision: https://secure.phabricator.com/D21055

+13 -7
+13 -7
src/aphront/response/AphrontResponse.php
··· 417 417 } 418 418 419 419 public function willBeginWrite() { 420 - if ($this->shouldCompressResponse()) { 421 - // Enable automatic compression here. Webservers sometimes do this for 422 - // us, but we now detect the absence of compression and warn users about 423 - // it so try to cover our bases more thoroughly. 424 - ini_set('zlib.output_compression', 1); 425 - } else { 426 - ini_set('zlib.output_compression', 0); 420 + // If we've already sent headers, these "ini_set()" calls will warn that 421 + // they have no effect. Today, this always happens because we're inside 422 + // a unit test, so just skip adjusting the setting. 423 + 424 + if (!headers_sent()) { 425 + if ($this->shouldCompressResponse()) { 426 + // Enable automatic compression here. Webservers sometimes do this for 427 + // us, but we now detect the absence of compression and warn users about 428 + // it so try to cover our bases more thoroughly. 429 + ini_set('zlib.output_compression', 1); 430 + } else { 431 + ini_set('zlib.output_compression', 0); 432 + } 427 433 } 428 434 } 429 435