From 700b5633e915a5c4954c63d56c5178b492e152b1 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 16 Apr 2024 15:23:14 +0200 Subject: [PATCH] allow setting the farm dir via an environment variable This allows us to preconfigure the farmer plugin in the Docker container. --- DokuWikiFarmCore.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/DokuWikiFarmCore.php b/DokuWikiFarmCore.php index 09e4adf..61951ff 100644 --- a/DokuWikiFarmCore.php +++ b/DokuWikiFarmCore.php @@ -409,17 +409,23 @@ protected function adjustCascade() protected function loadConfig() { $ini = DOKU_INC . 'conf/farm.ini'; - if (!file_exists($ini)) return; - $config = parse_ini_file($ini, true); - foreach (array_keys($this->config) as $section) { - if (isset($config[$section])) { - $this->config[$section] = array_merge( - $this->config[$section], - $config[$section] - ); + if (file_exists($ini)) { + $config = parse_ini_file($ini, true); + foreach (array_keys($this->config) as $section) { + if (isset($config[$section])) { + $this->config[$section] = array_merge( + $this->config[$section], + $config[$section] + ); + } } } + // farmdir setup can be done via environment + if($this->config['base']['farmdir'] === '' && isset($_ENV['DOKU_FARMDIR'])) { + $this->config['base']['farmdir'] = $_ENV['DOKU_FARMDIR']; + } + $this->config['base']['farmdir'] = trim($this->config['base']['farmdir']); $this->config['base']['farmhost'] = strtolower(trim($this->config['base']['farmhost'])); }