Skip to content

Commit 816c23c

Browse files
committed
Merge pull request #21923 from owncloud/fix-errors-after-install
Fix errors after install
2 parents 6973718 + 8a4e1fb commit 816c23c

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

lib/private/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private function readData() {
184184

185185
// Include file and merge config
186186
foreach ($configFiles as $file) {
187-
$filePointer = @fopen($file, 'r');
187+
$filePointer = file_exists($file) ? fopen($file, 'r') : false;
188188
if($file === $this->configFilePath &&
189189
$filePointer === false &&
190190
@!file_exists($this->configFilePath)) {

lib/private/log/owncloud.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ public static function init() {
4343
$defaultLogFile = $systemConfig->getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log';
4444
self::$logFile = $systemConfig->getValue("logfile", $defaultLogFile);
4545

46-
/*
47-
* Fall back to default log file if specified logfile does not exist
48-
* and can not be created. Error suppression is required in order to
49-
* not end up in the error handler which will try to log the error.
50-
* A better solution (compared to error suppression) would be checking
51-
* !is_writable(dirname(self::$logFile)) before touch(), but
52-
* is_writable() on directories used to be pretty unreliable on Windows
53-
* for at least some time.
54-
*/
55-
if (!file_exists(self::$logFile) && !@touch(self::$logFile)) {
56-
self::$logFile = $defaultLogFile;
46+
/**
47+
* Fall back to default log file if specified logfile does not exist
48+
* and can not be created.
49+
*/
50+
if (!file_exists(self::$logFile)) {
51+
if(!is_writable(dirname(self::$logFile))) {
52+
self::$logFile = $defaultLogFile;
53+
} else {
54+
if(!touch(self::$logFile)) {
55+
self::$logFile = $defaultLogFile;
56+
}
57+
}
5758
}
5859
}
5960

0 commit comments

Comments
 (0)