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

Remove PhabricatorStartup::getGlobal/setGlobal mechanism

Summary:
Ref T8424. Fixes T7114. This was envisioned as a per-request cache for reusing interpreters, but isn't a good fit for that in modern Phabricator.

In particular, it isn't loaded by the daemons, but they have equal need for per-request caching.

Since I finally need such a cache for Spaces, throw the old stuff away before I built a more modern cache.

Also resolves T7114 by dropping filtering on $_SERVER. I'm pretty sure this is the simplest fix, see D12977 for a bit more discussion.

Test Plan: Called `didFatal()` from somewhere in normal code and verified it was able to use the access log.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7114, T8424

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

+15 -44
-1
src/__phutil_library_map__.php
··· 3903 3903 'DivinerLiveBook' => array( 3904 3904 'DivinerDAO', 3905 3905 'PhabricatorPolicyInterface', 3906 - 'PhabricatorProjectInterface', 3907 3906 'PhabricatorDestructibleInterface', 3908 3907 ), 3909 3908 'DivinerLivePublisher' => 'DivinerPublisher',
+1 -1
src/aphront/configuration/AphrontApplicationConfiguration.php
··· 80 80 // This is the earliest we can get away with this, we need env config first. 81 81 PhabricatorAccessLog::init(); 82 82 $access_log = PhabricatorAccessLog::getLog(); 83 - PhabricatorStartup::setGlobal('log.access', $access_log); 83 + PhabricatorStartup::setAccessLog($access_log); 84 84 $access_log->setData( 85 85 array( 86 86 'R' => AphrontRequest::getHTTPHeader('Referer', '-'),
+14 -42
support/PhabricatorStartup.php
··· 39 39 40 40 private static $startTime; 41 41 private static $debugTimeLimit; 42 - private static $globals = array(); 42 + private static $accessLog; 43 43 private static $capturingOutput; 44 44 private static $rawInput; 45 45 private static $oldMemoryLimit; ··· 72 72 /** 73 73 * @task info 74 74 */ 75 - public static function setGlobal($key, $value) { 76 - self::validateGlobal($key); 77 - 78 - self::$globals[$key] = $value; 75 + public static function setAccessLog($access_log) { 76 + self::$accessLog = $access_log; 79 77 } 80 78 81 79 82 80 /** 83 81 * @task info 84 82 */ 85 - public static function getGlobal($key, $default = null) { 86 - self::validateGlobal($key); 87 - 88 - if (!array_key_exists($key, self::$globals)) { 89 - return $default; 90 - } 91 - 92 - return self::$globals[$key]; 93 - } 94 - 95 - /** 96 - * @task info 97 - */ 98 83 public static function getRawInput() { 99 84 return self::$rawInput; 100 85 } ··· 108 93 */ 109 94 public static function didStartup() { 110 95 self::$startTime = microtime(true); 111 - self::$globals = array(); 96 + self::$accessLog = null; 112 97 113 98 static $registered; 114 99 if (!$registered) { ··· 348 333 } 349 334 350 335 self::endOutputCapture(); 351 - $access_log = self::getGlobal('log.access'); 352 - 336 + $access_log = self::$accessLog; 353 337 if ($access_log) { 354 338 // We may end up here before the access log is initialized, e.g. from 355 339 // verifyPHP(). ··· 402 386 */ 403 387 private static function normalizeInput() { 404 388 // Replace superglobals with unfiltered versions, disrespect php.ini (we 405 - // filter ourselves) 406 - $filter = array(INPUT_GET, INPUT_POST, 407 - INPUT_SERVER, INPUT_ENV, INPUT_COOKIE, 389 + // filter ourselves). 390 + 391 + // NOTE: We don't filter INPUT_SERVER because we don't want to overwrite 392 + // changes made in "preamble.php". 393 + $filter = array( 394 + INPUT_GET, 395 + INPUT_POST, 396 + INPUT_ENV, 397 + INPUT_COOKIE, 408 398 ); 409 399 foreach ($filter as $type) { 410 400 $filtered = filter_input_array($type, FILTER_UNSAFE_RAW); ··· 412 402 continue; 413 403 } 414 404 switch ($type) { 415 - case INPUT_SERVER: 416 - $_SERVER = array_merge($_SERVER, $filtered); 417 - break; 418 405 case INPUT_GET: 419 406 $_GET = array_merge($_GET, $filtered); 420 407 break; ··· 547 534 "Request parameter '__path__' is set, but empty. Your rewrite rules ". 548 535 "are not configured correctly. The '__path__' should always ". 549 536 "begin with a '/'."); 550 - } 551 - } 552 - 553 - 554 - /** 555 - * @task validation 556 - */ 557 - private static function validateGlobal($key) { 558 - static $globals = array( 559 - 'log.access' => true, 560 - 'csrf.salt' => true, 561 - ); 562 - 563 - if (empty($globals[$key])) { 564 - throw new Exception("Access to unknown startup global '{$key}'!"); 565 537 } 566 538 } 567 539