1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-21 22:32:41 +01:00

Merge __init_env__.php into __init_script__.php

Summary: There are currently two files, but all scripts require both of them,
which is clearly silly. In the longer term I want to rewrite all of this init
stuff to be more structured (e.g., merge webroot/index.php and __init_script__
better) but this reduces the surface area of the ad-hoc "include files" API we
have now, at least.

Test Plan:
  - Grepped for __init_env__.php (no hits)
  - Ran a unit test (to test unit changes)
  - Ran a daemon (to test daemon changes)

Reviewers: jungejason, nh, tuomaspelkonen, aran

Reviewed By: jungejason

CC: aran, jungejason

Differential Revision: 976
This commit is contained in:
epriestley 2011-10-01 08:59:42 -07:00
parent ceceb47033
commit e4e5c39457
18 changed files with 35 additions and 20 deletions

View file

@ -33,3 +33,36 @@ phutil_load_library(dirname(__FILE__).'/../src/');
// NOTE: This is dangerous in general, but we know we're in a script context and
// are not vulnerable to CSRF.
AphrontWriteGuard::allowDangerousUnguardedWrites(true);
$include_path = ini_get('include_path');
ini_set('include_path', $include_path.':'.dirname(__FILE__).'/../../');
require_once dirname(dirname(__FILE__)).'/conf/__init_conf__.php';
$env = isset($_SERVER['PHABRICATOR_ENV'])
? $_SERVER['PHABRICATOR_ENV']
: getenv('PHABRICATOR_ENV');
if (!$env) {
echo "Define PHABRICATOR_ENV before running this script.\n";
exit(1);
}
$conf = phabricator_read_config_file($env);
$conf['phabricator.env'] = $env;
phutil_require_module('phabricator', 'infrastructure/env');
PhabricatorEnv::setEnvConfig($conf);
phutil_load_library('arcanist/src');
foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) {
phutil_load_library($library);
}
PhutilErrorHandler::initialize();
PhabricatorEventEngine::initialize();
$tz = PhabricatorEnv::getEnvConfig('phabricator.timezone');
if ($tz) {
date_default_timezone_set($tz);
}

View file

@ -75,7 +75,6 @@ $package_spec = array(
require_once dirname(__FILE__).'/__init_script__.php';
require_once dirname(__FILE__).'/__init_env__.php';
if ($argc != 2) {
$self = basename($argv[0]);

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'parser/xhpast/bin');

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
if ($argc !== 2) {
echo phutil_console_format(

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phabricator', 'infrastructure/daemon/control');
$control = new PhabricatorDaemonControl();

View file

@ -23,7 +23,6 @@ if ($argc > 1) {
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
require_once $root.'/externals/mimemailparser/MimeMailParser.class.php';
phutil_require_module(

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'symbols');
PhutilSymbolLoader::loadClass('PhabricatorRepository');

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'future/exec');

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
if (empty($argv[1])) {
echo "usage: index_one_commit.php <commit_name>\n";

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
$users = id(new PhabricatorUser())->loadAll();
echo "Indexing ".count($users)." users";

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
// TODO: Get rid of this script eventually, once this stuff is better-formalized
// in Timeline consumers.

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
ini_set('memory_limit', -1);
$tasks = id(new ManiphestTask())->loadAll();

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phabricator', 'infrastructure/setup/sql');

View file

@ -19,7 +19,6 @@
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
require_once $root.'/scripts/__init_env__.php';
phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'future/exec');

View file

@ -30,9 +30,6 @@ abstract class PhabricatorDaemon extends PhutilDaemon {
$phabricator = phutil_get_library_root('phabricator');
$root = dirname($phabricator);
require_once $root.'/scripts/__init_env__.php';
// Daemons may perform writes.
AphrontWriteGuard::allowDangerousUnguardedWrites(true);
require_once $root.'/scripts/__init_script__.php';
}
}

View file

@ -8,7 +8,6 @@
phutil_require_module('phabricator', 'aphront/console/plugin/errorlog/api');
phutil_require_module('phabricator', 'aphront/console/plugin/event/api');
phutil_require_module('phabricator', 'aphront/writeguard');
phutil_require_module('phutil', 'daemon/base');
phutil_require_module('phutil', 'moduleutils');

View file

@ -44,7 +44,7 @@ abstract class PhabricatorTestCase extends ArcanistPhutilTestCase {
protected function willRunTests() {
$root = dirname(phutil_get_library_root('phabricator'));
require_once $root.'/scripts/__init_env__.php';
require_once $root.'/scripts/__init_script__.php';
$config = $this->getComputedConfiguration();