From 2c34af72e18c7ba577591d389ca1eff2c4bc9eaf Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 23 Aug 2017 14:20:39 +1200 Subject: [PATCH 1/2] ENHANCEMENT Log user constants during CI for debugging improvements --- .travis.yml | 3 +++ src/includes/constants.php | 5 ++--- tests/dump_constants.php | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 tests/dump_constants.php diff --git a/.travis.yml b/.travis.yml index 31a59d498..29b699477 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,6 +78,9 @@ before_script: # Bootstrap dependencies - if [[ $PHPUNIT_TEST == cms ]] || [[ $BEHAT_TEST == cms ]]; then php ./cms/tests/bootstrap/mysite.php; fi +# Log constants to CI for debugging purposes + - php ./tests/dump_constants.php + # Start behat services - if [[ $BEHAT_TEST ]]; then echo 'SS_BASE_URL=http://localhost:8080/' >> .env; fi - if [[ $BEHAT_TEST ]]; then mkdir artifacts; fi diff --git a/src/includes/constants.php b/src/includes/constants.php index 91ce3b9d6..d774de2b3 100644 --- a/src/includes/constants.php +++ b/src/includes/constants.php @@ -2,7 +2,6 @@ use Dotenv\Dotenv; use Dotenv\Exception\InvalidPathException; -use SilverStripe\Control\Util\IPUtils; use SilverStripe\Core\TempFolder; /** @@ -18,14 +17,14 @@ use SilverStripe\Core\TempFolder; * See Director::baseFolder(). Can be overwritten by Config::modify()->set(Director::class, 'alternate_base_folder', ). * - TEMP_FOLDER: Absolute path to temporary folder, used for manifest and template caches. Example: "/var/tmp" * See getTempFolder(). No trailing slash. + * - ASSETS_DIR: Dir for assets folder. e.g. "assets" + * - ASSETS_PATH: Full path to assets folder. e.g. "/var/www/my-webroot/assets" * - THEMES_DIR: Path relative to webroot, e.g. "themes" * - THEMES_PATH: Absolute filepath, e.g. "/var/www/my-webroot/themes" * - FRAMEWORK_DIR: Path relative to webroot, e.g. "framework" * - FRAMEWORK_PATH:Absolute filepath, e.g. "/var/www/my-webroot/framework" * - THIRDPARTY_DIR: Path relative to webroot, e.g. "framework/thirdparty" * - THIRDPARTY_PATH: Absolute filepath, e.g. "/var/www/my-webroot/framework/thirdparty" - * - TRUSTED_PROXY: true or false, depending on whether the X-Forwarded-* HTTP - * headers from the given client are trustworthy (e.g. from a reverse proxy). */ require_once __DIR__ . '/functions.php'; diff --git a/tests/dump_constants.php b/tests/dump_constants.php new file mode 100644 index 000000000..eaea580ee --- /dev/null +++ b/tests/dump_constants.php @@ -0,0 +1,11 @@ + $value) { + echo " - {$name}: '{$value}'\n"; +} +echo "==============================\n"; From 1b087221d221523c76755e5a684f5b408c306ef7 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 23 Aug 2017 14:48:28 +1200 Subject: [PATCH 2/2] BUG Fix BASE_URL on CLI Fixes #7256 --- src/includes/constants.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/includes/constants.php b/src/includes/constants.php index d774de2b3..c408a3457 100644 --- a/src/includes/constants.php +++ b/src/includes/constants.php @@ -82,8 +82,8 @@ if (!defined('BASE_URL')) { $urlSegmentToRemove = substr($path, strlen(BASE_PATH)); if (substr($_SERVER['SCRIPT_NAME'], -strlen($urlSegmentToRemove)) == $urlSegmentToRemove) { $baseURL = substr($_SERVER['SCRIPT_NAME'], 0, -strlen($urlSegmentToRemove)); - // Normalise slashes to '/' and rtrim('/') - return rtrim(str_replace('\\', '/', $baseURL), '/'); + // ltrim('.'), normalise slashes to '/', and rtrim('/') + return rtrim(str_replace('\\', '/', ltrim($baseURL, '.')), '/'); } }