|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -error_reporting(E_ALL | E_STRICT); |
4 |
| -ini_set('display_errors', 1); |
5 |
| - |
6 |
| -$include_path = ini_get('include_path'); |
7 |
| -ini_set( |
8 |
| - 'include_path', |
9 |
| - $include_path.PATH_SEPARATOR.dirname(__FILE__).'/../../'); |
10 |
| -@include_once 'libphutil/scripts/__init_script__.php'; |
11 |
| -if (!@constant('__LIBPHUTIL__')) { |
12 |
| - echo "ERROR: Unable to load libphutil. Update your PHP 'include_path' to ". |
13 |
| - "include the parent directory of libphutil/.\n"; |
14 |
| - exit(1); |
15 |
| -} |
16 |
| - |
17 |
| -phutil_load_library(dirname(__FILE__).'/../src/'); |
18 |
| - |
19 |
| -// NOTE: This is dangerous in general, but we know we're in a script context and |
20 |
| -// are not vulnerable to CSRF. |
21 |
| -AphrontWriteGuard::allowDangerousUnguardedWrites(true); |
22 |
| - |
23 |
| -require_once dirname(dirname(__FILE__)).'/conf/__init_conf__.php'; |
24 |
| - |
25 |
| -$env = isset($_SERVER['PHABRICATOR_ENV']) |
26 |
| - ? $_SERVER['PHABRICATOR_ENV'] |
27 |
| - : getenv('PHABRICATOR_ENV'); |
28 |
| -if (!$env) { |
29 |
| - echo phutil_console_wrap( |
30 |
| - phutil_console_format( |
31 |
| - "**ERROR**: PHABRICATOR_ENV Not Set\n\n". |
32 |
| - "Define the __PHABRICATOR_ENV__ environment variable before running ". |
33 |
| - "this script. You can do it on the command line like this:\n\n". |
34 |
| - " $ PHABRICATOR_ENV=__custom/myconfig__ %s ...\n\n". |
35 |
| - "Replace __custom/myconfig__ with the path to your configuration file. ". |
36 |
| - "For more information, see the 'Configuration Guide' in the ". |
37 |
| - "Phabricator documentation.\n\n", |
38 |
| - $argv[0])); |
39 |
| - exit(1); |
40 |
| -} |
41 |
| - |
42 |
| -$conf = phabricator_read_config_file($env); |
43 |
| -$conf['phabricator.env'] = $env; |
44 |
| - |
45 |
| -PhabricatorEnv::setEnvConfig($conf); |
46 |
| - |
47 |
| -phutil_load_library('arcanist/src'); |
48 |
| - |
49 |
| -foreach (PhabricatorEnv::getEnvConfig('load-libraries') as $library) { |
50 |
| - phutil_load_library($library); |
51 |
| -} |
52 |
| - |
53 |
| -PhutilErrorHandler::initialize(); |
54 |
| -PhabricatorEventEngine::initialize(); |
55 |
| - |
56 |
| -$tz = PhabricatorEnv::getEnvConfig('phabricator.timezone'); |
57 |
| -if ($tz) { |
58 |
| - date_default_timezone_set($tz); |
| 3 | +function init_phabricator_script() { |
| 4 | + error_reporting(E_ALL | E_STRICT); |
| 5 | + ini_set('display_errors', 1); |
| 6 | + |
| 7 | + $include_path = ini_get('include_path'); |
| 8 | + ini_set( |
| 9 | + 'include_path', |
| 10 | + $include_path.PATH_SEPARATOR.dirname(__FILE__).'/../../'); |
| 11 | + @include_once 'libphutil/scripts/__init_script__.php'; |
| 12 | + if (!@constant('__LIBPHUTIL__')) { |
| 13 | + echo "ERROR: Unable to load libphutil. Update your PHP 'include_path' to ". |
| 14 | + "include the parent directory of libphutil/.\n"; |
| 15 | + exit(1); |
| 16 | + } |
| 17 | + |
| 18 | + phutil_load_library('arcanist/src'); |
| 19 | + phutil_load_library(dirname(__FILE__).'/../src/'); |
| 20 | + |
| 21 | + PhabricatorEnv::initializeScriptEnvironment(); |
59 | 22 | }
|
60 | 23 |
|
61 |
| -$translation = PhabricatorEnv::newObjectFromConfig('translation.provider'); |
62 |
| -PhutilTranslator::getInstance() |
63 |
| - ->setLanguage($translation->getLanguage()) |
64 |
| - ->addTranslations($translation->getTranslations()); |
65 |
| - |
66 |
| -// Append any paths to $PATH if we need to. |
67 |
| -$paths = PhabricatorEnv::getEnvConfig('environment.append-paths'); |
68 |
| -if (!empty($paths)) { |
69 |
| - $current_env_path = getenv('PATH'); |
70 |
| - $new_env_paths = implode(PATH_SEPARATOR, $paths); |
71 |
| - putenv('PATH='.$current_env_path.PATH_SEPARATOR.$new_env_paths); |
72 |
| -} |
| 24 | +init_phabricator_script(); |
0 commit comments