diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php b/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php index a59fe076308bd5a0736132357a5dfa1348c11df6..85d7b7a2d1ff0d9df631f4656abc6af8542f57ce 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 e06e70ed05c92e162163e2ae3d19c06321b5b673..979b623a9dbf1593713c696d4a18d767f038f674 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