diff --git a/lib/private/Config.php b/lib/private/Config.php index 0e8d07955af06..20286ae6f14da 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -197,31 +197,42 @@ private function readData() { } http_response_code(500); - die(sprintf('FATAL: Could not open the config file %s', $file)); + die(sprintf('FATAL: Could not open the config file: %s' . PHP_EOL, basename($file))); } // Try to acquire a file lock if (!flock($filePointer, LOCK_SH)) { - throw new \Exception(sprintf('Could not acquire a shared lock on the config file %s', $file)); + http_response_code(500); + die(sprintf('FATAL: Could not acquire a shared lock on the config file: %s' . PHP_EOL, basename($file))); } try { + // wrap with output buffer to catch some problems and avoid generating uncontrolled output + ob_start(); include $file; + $ob_length = ob_get_length(); + ob_end_clean(); + // syntax issues in the config file like leading spaces cause PHP to send output + if ($ob_length > 0 && !defined('PHPUNIT_RUN')) { // indicator of leading content discovered + $errorMessage = sprintf('FATAL: Config file has leading content, please remove everything before "configFilePath) { + http_response_code(500); + die(sprintf('FATAL: Conflicting version value in the loaded config file: %s' . PHP_EOL, basename($file))); + } $this->cache = array_merge($this->cache, $CONFIG); } }