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

Don't load extensions when running unit tests

Summary: Fixes T15519

Test Plan:
- Run `arc unit` with a bogus extension in load-libraries and see it get slightly farther than before (it still fails because it tries to run the storage-creation script which loads extensions)
- With D26704 also installed run `arc unit` and see it only try to extract core libraries.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15519

Differential Revision: https://we.phorge.it/D26707

Pppery 1b008e40 d2188214

+29 -10
+4 -1
scripts/init/lib.php
··· 28 28 phutil_load_library(dirname(__FILE__).'/../../src/'); 29 29 30 30 $config_optional = $options['config.optional']; 31 - PhabricatorEnv::initializeScriptEnvironment($config_optional); 31 + $no_extensions = $options['no-extensions'] ?? false; 32 + PhabricatorEnv::initializeScriptEnvironment( 33 + $config_optional, 34 + $no_extensions); 32 35 }
+15 -8
src/infrastructure/env/PhabricatorEnv.php
··· 68 68 * @phutil-external-symbol class PhabricatorStartup 69 69 */ 70 70 public static function initializeWebEnvironment() { 71 - self::initializeCommonEnvironment(false); 71 + self::initializeCommonEnvironment(false, false); 72 72 } 73 73 74 - public static function initializeScriptEnvironment($config_optional) { 75 - self::initializeCommonEnvironment($config_optional); 74 + public static function initializeScriptEnvironment( 75 + $config_optional, 76 + $no_extensions) { 77 + self::initializeCommonEnvironment($config_optional, $no_extensions); 76 78 77 79 // NOTE: This is dangerous in general, but we know we're in a script context 78 80 // and are not vulnerable to CSRF. ··· 88 90 } 89 91 90 92 91 - private static function initializeCommonEnvironment($config_optional) { 93 + private static function initializeCommonEnvironment( 94 + $config_optional, 95 + $no_extensions) { 92 96 PhutilErrorHandler::initialize(); 93 97 94 98 self::resetUmask(); 95 - self::buildConfigurationSourceStack($config_optional); 99 + self::buildConfigurationSourceStack($config_optional, $no_extensions); 96 100 97 101 // Force a valid timezone. If both PHP and Phabricator configuration are 98 102 // invalid, use UTC. ··· 179 183 } 180 184 } 181 185 182 - private static function buildConfigurationSourceStack($config_optional) { 186 + private static function buildConfigurationSourceStack( 187 + $config_optional, $no_extensions) { 183 188 self::dropConfigCache(); 184 189 185 190 $stack = new PhabricatorConfigStackSource(); ··· 203 208 // If the install overrides the database adapter, we might need to load 204 209 // the database adapter class before we can push on the database config. 205 210 // This config is locked and can't be edited from the web UI anyway. 206 - foreach (self::getEnvConfig('load-libraries') as $library) { 207 - phutil_load_library($library); 211 + if (!$no_extensions) { 212 + foreach (self::getEnvConfig('load-libraries') as $library) { 213 + phutil_load_library($library); 214 + } 208 215 } 209 216 210 217 // Drop any class map caches, since they will have generated without
+10 -1
src/infrastructure/testing/PhabricatorTestCase.php
··· 57 57 return $config; 58 58 } 59 59 60 + /** @phutil-external-symbol function init_phabricator_script */ 60 61 public function willRunTestCases(array $test_cases) { 61 62 $root = dirname(phutil_get_library_root('phabricator')); 62 - require_once $root.'/scripts/__init_script__.php'; 63 + if (!function_exists('init_phabricator_script')) { 64 + // Run the initialization routines only if nothing else already did 65 + require_once $root.'/scripts/init/lib.php'; 66 + init_phabricator_script( 67 + array( 68 + 'config.optional' => false, 69 + 'no-extensions' => true, 70 + )); 71 + } 63 72 64 73 $config = $this->getComputedConfiguration(); 65 74