diff --git a/index.php b/index.php index 04db613d..69c1d161 100644 --- a/index.php +++ b/index.php @@ -79,36 +79,17 @@ public function __construct(string $baseDir) { $this->baseDir = $baseDir; if ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { - $configDir = rtrim($dir, '/'); + $configFileName = rtrim($dir, '/') . '/config.php'; } else { - $configDir = $this->baseDir . '/../config'; + $configFileName = $this->baseDir . '/../config/config.php'; } - - $configFiles = [$configDir . '/config.php']; - - if (!file_exists($configFiles[0])) { + if (!file_exists($configFileName)) { throw new \Exception('Could not find config.php. Is this file in the "updater" subfolder of Nextcloud?'); } - $extraConfigFiles = glob($configDir . '/*.config.php'); - if (is_array($extraConfigFiles)) { - natsort($extraConfigFiles); - $configFiles = array_merge($configFiles, $extraConfigFiles); - } - - foreach ($configFiles as $configFile) { - /** - * @psalm-suppress UnresolvableInclude - * @var mixed $CONFIG - */ - require_once $configFile; - - if (isset($CONFIG) && is_array($CONFIG)) { - $this->configValues = array_merge($this->configValues, $CONFIG); - } - - unset($CONFIG); - } + /** @var array $CONFIG */ + require_once $configFileName; + $this->configValues = $CONFIG; if (php_sapi_name() !== 'cli' && ($this->configValues['upgrade.disable-web'] ?? false)) { // updater disabled diff --git a/lib/Updater.php b/lib/Updater.php index 14f4dca4..37d112d1 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -41,36 +41,17 @@ public function __construct(string $baseDir) { $this->baseDir = $baseDir; if ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { - $configDir = rtrim($dir, '/'); + $configFileName = rtrim($dir, '/') . '/config.php'; } else { - $configDir = $this->baseDir . '/../config'; + $configFileName = $this->baseDir . '/../config/config.php'; } - - $configFiles = [$configDir . '/config.php']; - - if (!file_exists($configFiles[0])) { + if (!file_exists($configFileName)) { throw new \Exception('Could not find config.php. Is this file in the "updater" subfolder of Nextcloud?'); } - $extraConfigFiles = glob($configDir . '/*.config.php'); - if (is_array($extraConfigFiles)) { - natsort($extraConfigFiles); - $configFiles = array_merge($configFiles, $extraConfigFiles); - } - - foreach ($configFiles as $configFile) { - /** - * @psalm-suppress UnresolvableInclude - * @var mixed $CONFIG - */ - require_once $configFile; - - if (isset($CONFIG) && is_array($CONFIG)) { - $this->configValues = array_merge($this->configValues, $CONFIG); - } - - unset($CONFIG); - } + /** @var array $CONFIG */ + require_once $configFileName; + $this->configValues = $CONFIG; if (php_sapi_name() !== 'cli' && ($this->configValues['upgrade.disable-web'] ?? false)) { // updater disabled diff --git a/updater.phar b/updater.phar index de6e25b1..3e760b1b 100755 Binary files a/updater.phar and b/updater.phar differ