@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.

Fix an issue where unexpected debugging output would run afoul of automatic compression

Summary:
If you put "echo" or "print" statements into the code at random places (as I frequently do during development), they would emit before we enabled compression.

This would confuse the compression mechanism and browser. I tried using `headers_sent()` to selectively disable compression but that didn't appear to fix this interaction (I think emitting this text does not cause headers to send, but does let contet escape into some buffer which the compressor can not access).

Instead, push the header down a little bit so it renders after we activate compression.

Also make it slightly fancier / more hideous. WOW.

Test Plan: {F2122927}

Reviewers: chad

Reviewed By: chad

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

+34 -13
+1 -12
src/aphront/configuration/AphrontApplicationConfiguration.php
··· 303 303 phlog($unexpected_output); 304 304 305 305 if ($response instanceof AphrontWebpageResponse) { 306 - echo phutil_tag( 307 - 'div', 308 - array( 309 - 'style' => 310 - 'background: #eeddff;'. 311 - 'white-space: pre-wrap;'. 312 - 'z-index: 200000;'. 313 - 'position: relative;'. 314 - 'padding: 8px;'. 315 - 'font-family: monospace', 316 - ), 317 - $unexpected_output); 306 + $response->setUnexpectedOutput($unexpected_output); 318 307 } 319 308 } 320 309
+33 -1
src/aphront/response/AphrontWebpageResponse.php
··· 3 3 final class AphrontWebpageResponse extends AphrontHTMLResponse { 4 4 5 5 private $content; 6 + private $unexpectedOutput; 6 7 7 8 public function setContent($content) { 8 9 $this->content = $content; 9 10 return $this; 10 11 } 11 12 13 + public function setUnexpectedOutput($unexpected_output) { 14 + $this->unexpectedOutput = $unexpected_output; 15 + return $this; 16 + } 17 + 18 + public function getUnexpectedOutput() { 19 + return $this->unexpectedOutput; 20 + } 21 + 12 22 public function buildResponseString() { 13 - return hsprintf('%s', $this->content); 23 + $unexpected_output = $this->getUnexpectedOutput(); 24 + if (strlen($unexpected_output)) { 25 + $style = array( 26 + 'background: linear-gradient(180deg, #eeddff, #ddbbff);', 27 + 'white-space: pre-wrap;', 28 + 'z-index: 200000;', 29 + 'position: relative;', 30 + 'padding: 16px;', 31 + 'font-family: monospace;', 32 + 'text-shadow: 1px 1px 1px white;', 33 + ); 34 + 35 + $unexpected_header = phutil_tag( 36 + 'div', 37 + array( 38 + 'style' => implode(' ', $style), 39 + ), 40 + $unexpected_output); 41 + } else { 42 + $unexpected_header = ''; 43 + } 44 + 45 + return hsprintf('%s%s', $unexpected_header, $this->content); 14 46 } 15 47 16 48 }