Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13992475
D16502.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D16502.id.diff
View Options
diff --git a/scripts/__init_script__.php b/scripts/__init_script__.php
--- a/scripts/__init_script__.php
+++ b/scripts/__init_script__.php
@@ -1,24 +1,3 @@
<?php
-function init_phabricator_script() {
- error_reporting(E_ALL | E_STRICT);
- ini_set('display_errors', 1);
-
- $include_path = ini_get('include_path');
- ini_set(
- 'include_path',
- $include_path.PATH_SEPARATOR.dirname(__FILE__).'/../../');
- @include_once 'libphutil/scripts/__init_script__.php';
- if (!@constant('__LIBPHUTIL__')) {
- echo "ERROR: Unable to load libphutil. Update your PHP 'include_path' to ".
- "include the parent directory of libphutil/.\n";
- exit(1);
- }
-
- phutil_load_library('arcanist/src');
- phutil_load_library(dirname(__FILE__).'/../src/');
-
- PhabricatorEnv::initializeScriptEnvironment();
-}
-
-init_phabricator_script();
+require_once dirname(__FILE__).'/init/init-script.php';
diff --git a/scripts/init/init-script.php b/scripts/init/init-script.php
new file mode 100644
--- /dev/null
+++ b/scripts/init/init-script.php
@@ -0,0 +1,10 @@
+<?php
+
+// Initialize a standard script.
+
+require_once dirname(__FILE__).'/lib.php';
+
+init_phabricator_script(
+ array(
+ 'config.optional' => false,
+ ));
diff --git a/scripts/init/init-setup.php b/scripts/init/init-setup.php
new file mode 100644
--- /dev/null
+++ b/scripts/init/init-setup.php
@@ -0,0 +1,12 @@
+<?php
+
+// Initialize a setup script which may run before database connections have
+// been configured. Scripts initialized in this way ignore database errors
+// while building database configuration and continue.
+
+require_once dirname(__FILE__).'/lib.php';
+
+init_phabricator_script(
+ array(
+ 'config.optional' => true,
+ ));
diff --git a/scripts/__init_script__.php b/scripts/init/lib.php
copy from scripts/__init_script__.php
copy to scripts/init/lib.php
--- a/scripts/__init_script__.php
+++ b/scripts/init/lib.php
@@ -1,13 +1,13 @@
<?php
-function init_phabricator_script() {
+function init_phabricator_script(array $options) {
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
$include_path = ini_get('include_path');
ini_set(
'include_path',
- $include_path.PATH_SEPARATOR.dirname(__FILE__).'/../../');
+ $include_path.PATH_SEPARATOR.dirname(__FILE__).'/../../../');
@include_once 'libphutil/scripts/__init_script__.php';
if (!@constant('__LIBPHUTIL__')) {
echo "ERROR: Unable to load libphutil. Update your PHP 'include_path' to ".
@@ -16,9 +16,8 @@
}
phutil_load_library('arcanist/src');
- phutil_load_library(dirname(__FILE__).'/../src/');
+ phutil_load_library(dirname(__FILE__).'/../../src/');
- PhabricatorEnv::initializeScriptEnvironment();
+ $config_optional = $options['config.optional'];
+ PhabricatorEnv::initializeScriptEnvironment($config_optional);
}
-
-init_phabricator_script();
diff --git a/scripts/setup/manage_config.php b/scripts/setup/manage_config.php
--- a/scripts/setup/manage_config.php
+++ b/scripts/setup/manage_config.php
@@ -2,7 +2,7 @@
<?php
$root = dirname(dirname(dirname(__FILE__)));
-require_once $root.'/scripts/__init_script__.php';
+require_once $root.'/scripts/init/init-setup.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('manage configuration'));
diff --git a/scripts/sql/manage_storage.php b/scripts/sql/manage_storage.php
--- a/scripts/sql/manage_storage.php
+++ b/scripts/sql/manage_storage.php
@@ -2,7 +2,7 @@
<?php
$root = dirname(dirname(dirname(__FILE__)));
-require_once $root.'/scripts/__init_script__.php';
+require_once $root.'/scripts/init/init-setup.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('manage Phabricator storage and schemata'));
diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php
--- a/src/infrastructure/env/PhabricatorEnv.php
+++ b/src/infrastructure/env/PhabricatorEnv.php
@@ -68,11 +68,11 @@
* @phutil-external-symbol class PhabricatorStartup
*/
public static function initializeWebEnvironment() {
- self::initializeCommonEnvironment();
+ self::initializeCommonEnvironment(false);
}
- public static function initializeScriptEnvironment() {
- self::initializeCommonEnvironment();
+ public static function initializeScriptEnvironment($config_optional) {
+ self::initializeCommonEnvironment($config_optional);
// NOTE: This is dangerous in general, but we know we're in a script context
// and are not vulnerable to CSRF.
@@ -88,11 +88,11 @@
}
- private static function initializeCommonEnvironment() {
+ private static function initializeCommonEnvironment($config_optional) {
PhutilErrorHandler::initialize();
self::resetUmask();
- self::buildConfigurationSourceStack();
+ self::buildConfigurationSourceStack($config_optional);
// Force a valid timezone. If both PHP and Phabricator configuration are
// invalid, use UTC.
@@ -174,7 +174,7 @@
}
}
- private static function buildConfigurationSourceStack() {
+ private static function buildConfigurationSourceStack($config_optional) {
self::dropConfigCache();
$stack = new PhabricatorConfigStackSource();
@@ -235,6 +235,14 @@
// If the database is not available, just skip this configuration
// source. This happens during `bin/storage upgrade`, `bin/conf` before
// schema setup, etc.
+ } catch (AphrontConnectionQueryException $ex) {
+ if (!$config_optional) {
+ throw $ex;
+ }
+ } catch (AphrontInvalidCredentialsQueryException $ex) {
+ if (!$config_optional) {
+ throw $ex;
+ }
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 23, 4:56 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6720538
Default Alt Text
D16502.id.diff (5 KB)
Attached To
Mode
D16502: Continue on bad database configuration from select scripts
Attached
Detach File
Event Timeline
Log In to Comment