diff --git a/.gitignore b/.gitignore index d2c98d9..415be55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,38 @@ # NOTE: Thinking about adding files created by your operating system, IDE, # or text editor here? Don't! Add them to your per-user .gitignore instead. # Diviner /docs/ /.divinercache/ # XHPAST /support/xhpast/*.a /support/xhpast/*.o /support/xhpast/parser.yacc.output /support/xhpast/node_names.hpp /support/xhpast/xhpast /src/parser/xhpast/bin/xhpast ## NOTE: Don't .gitignore these files! Even though they're build artifacts, we ## want to check them in so users can build xhpast without flex/bison. # /support/xhpast/parser.yacc.cpp # /support/xhpast/parser.yacc.hpp # /support/xhpast/scanner.lex.cpp # /support/xhpast/scanner.lex.hpp # This is an OS X build artifact. /support/xhpast/xhpast.dSYM # This is a Windows build artifact. /support/xhpast/xhpast.exe # libphutil /src/.phutil_module_cache /support/phutiltestlib/.phutil_module_cache # This file overrides "default.pem" if present. /resources/ssl/custom.pem # User extensions +/externals/includes/* /src/extensions/* diff --git a/externals/includes/README b/externals/includes/README new file mode 100644 index 0000000..4b2f77f --- /dev/null +++ b/externals/includes/README @@ -0,0 +1,3 @@ +This directory is added to the PHP include path. You can symlink things here +if you have control over directory setup but not over PHP configuration (for +instance, in Homebrew). \ No newline at end of file diff --git a/scripts/__init_script__.php b/scripts/__init_script__.php index 2fb893f..12de287 100644 --- a/scripts/__init_script__.php +++ b/scripts/__init_script__.php @@ -1,95 +1,101 @@ 0) { ob_end_clean(); } error_reporting(E_ALL | E_STRICT); $config_map = array( // Always display script errors. Without this, they may not appear, which is // unhelpful when users encounter a problem. On the web this is a security // concern because you don't want to expose errors to clients, but in a // script context we always want to show errors. 'display_errors' => true, - // Send script error messages to the server's error_log setting. + // Send script error messages to the server's `error_log` setting. 'log_errors' => true, // Set the error log to the default, so errors go to stderr. Without this // errors may end up in some log, and users may not know where the log is // or check it. 'error_log' => null, // XDebug raises a fatal error if the call stack gets too deep, but the // default setting is 100, which we may exceed legitimately with module // includes (and in other cases, like recursive filesystem operations // applied to 100+ levels of directory nesting). Stop it from triggering: // we explicitly limit recursive algorithms which should be limited. // After Feb 2014, XDebug inteprets a value of 0 to mean "do not allow any // function calls". Previously, 0 effectively disabled this check. For // context, see T5027. 'xdebug.max_nesting_level' => PHP_INT_MAX, // Don't limit memory, doing so just generally just prevents us from // processing large inputs without many tangible benefits. 'memory_limit' => -1, ); foreach ($config_map as $config_key => $config_value) { ini_set($config_key, $config_value); } if (!ini_get('date.timezone')) { // If the timezone isn't set, PHP issues a warning whenever you try to parse // a date (like those from Git or Mercurial logs), even if the date contains // timezone information (like "PST" or "-0700") which makes the // environmental timezone setting is completely irrelevant. We never rely on // the system timezone setting in any capacity, so prevent PHP from flipping // out by setting it to a safe default (UTC) if it isn't set to some other // value. date_default_timezone_set('UTC'); } + // Adjust `include_path`. + ini_set('include_path', implode(PATH_SEPARATOR, array( + dirname(dirname(__FILE__)).'/externals/includes', + ini_get('include_path'), + ))); + // Disable the insanely dangerous XML entity loader by default. if (function_exists('libxml_disable_entity_loader')) { libxml_disable_entity_loader(true); } // Now, load libphutil. $root = dirname(dirname(__FILE__)); require_once $root.'/src/__phutil_library_init__.php'; PhutilErrorHandler::initialize(); // If possible, install a signal handler for SIGHUP which prints the current // backtrace out to a named file. This is particularly helpful in debugging // hung/spinning processes. if (function_exists('pcntl_signal')) { pcntl_signal(SIGHUP, '__phutil_signal_handler__'); } } function __phutil_signal_handler__($signal_number) { $e = new Exception(); $pid = getmypid(); // Some phabricator daemons may not be attached to a terminal. Filesystem::writeFile( sys_get_temp_dir().'/phabricator_backtrace_'.$pid, $e->getTraceAsString()); } __phutil_init_script__();