From eb6edb27399b478f15f3f00f33de540fe39a5867 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 17 Feb 2020 09:10:10 -0800 Subject: [PATCH] Restore old expanded include path rules for workflows which fall through Summary: Ref T13490. Historically, "arc" was eager to load external libraries from many locations. I plan to make this significantly more structured/safer in the future (see T5055), but this rule got dropped as the "experimental" and "wilds" branches collapsed to "master". Restore "next to arcanist" and "inside externals/includes" as valid search locations for classic workflows. Test Plan: Ran "arc" commands in a working copy with a "load" library configured. Maniphest Tasks: T13490 Differential Revision: https://secure.phabricator.com/D21004 --- scripts/arcanist.php | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/scripts/arcanist.php b/scripts/arcanist.php index 37441929..44b718e3 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -5,6 +5,43 @@ sanity_check_environment(); require_once dirname(__FILE__).'/__init_script__.php'; +/** + * Adjust 'include_path' to add locations where we'll search for libraries. + * We look in these places: + * + * - Next to 'arcanist/'. + * - Anywhere in the normal PHP 'include_path'. + * - Inside 'arcanist/externals/includes/'. + */ +function arcanist_adjust_php_include_path() { + // The 'arcanist/' directory. + $arcanist_dir = dirname(dirname(__FILE__)); + + // The parent directory of 'arcanist/'. + $parent_dir = dirname($arcanist_dir); + + // The 'arcanist/externals/includes/' directory. + $include_dir = implode( + DIRECTORY_SEPARATOR, + array( + $arcanist_dir, + 'externals', + 'includes', + )); + + $php_include_path = ini_get('include_path'); + $php_include_path = implode( + PATH_SEPARATOR, + array( + $parent_dir, + $php_include_path, + $include_dir, + )); + + ini_set('include_path', $php_include_path); +} +arcanist_adjust_php_include_path(); + ini_set('memory_limit', -1); $original_argv = $argv; @@ -646,7 +683,7 @@ function arcanist_load_libraries( $error = null; try { - require_once $location.'/__phutil_library_init__.php'; + phutil_load_library($location); } catch (PhutilBootloaderException $ex) { $error = pht( "Failed to load phutil library at location '%s'. This library ".