From b9342a13cc43e4e2e9c186c73bb244d4a12db71e Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 25 Oct 2012 10:35:42 -0400 Subject: [PATCH] Fixed problem with relative paths passed to CLI tools. --- .../src/VuFindConsole/Controller/AbstractBase.php | 7 +++++++ public/index.php | 3 +++ 2 files changed, 10 insertions(+) diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php b/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php index a59fe076308..85d7b7a2d1f 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php @@ -56,6 +56,13 @@ class AbstractBase extends AbstractActionController // Get access to information about the CLI request. $this->consoleOpts = new Getopt(array()); + + // Switch the context back to the original working directory so that + // relative paths work as expected. (This constant is set in + // public/index.php) + if (defined('ORIGINAL_WORKING_DIRECTORY')) { + chdir(ORIGINAL_WORKING_DIRECTORY); + } } /** diff --git a/public/index.php b/public/index.php index e06e70ed05c..979b623a9db 100644 --- a/public/index.php +++ b/public/index.php @@ -23,6 +23,9 @@ defined('APPLICATION_ENV') defined('LOCAL_OVERRIDE_DIR') || define('LOCAL_OVERRIDE_DIR', (getenv('VUFIND_LOCAL_DIR') ? getenv('VUFIND_LOCAL_DIR') : '')); +// Save original working directory in case we need to remember our context, then +// switch to the application directory for convenience: +define('ORIGINAL_WORKING_DIRECTORY', getcwd()); chdir(APPLICATION_PATH); // Ensure vendor/ is on include_path; some PEAR components may not load correctly -- GitLab