Fix errors after install
When installing ownCloud the first time the first thing that an admin saw was an error message: > Error PHP touch(): Unable to create file owncloud.log because Permission denied at /var/www/owncloud/lib/private/log/owncloud.php#48 Or something related. This lead to a lot confusion as can be seen in our forum and in our issue tracker. This change should make the error messages disappear in most cases (e.g. where the file can actually be written). To test this: 1. On master install ownCloud and check owncloud.log => Error message 2. On this branch install ownCloud and check owncloud.log => No error message Fixes https://github.com/owncloud/core/issues/13736 and https://github.com/owncloud/core/issues/12893
This commit is contained in:
parent
f383332d83
commit
8a4e1fbecd
|
@ -184,7 +184,7 @@ class Config {
|
||||||
|
|
||||||
// Include file and merge config
|
// Include file and merge config
|
||||||
foreach ($configFiles as $file) {
|
foreach ($configFiles as $file) {
|
||||||
$filePointer = @fopen($file, 'r');
|
$filePointer = file_exists($file) ? fopen($file, 'r') : false;
|
||||||
if($file === $this->configFilePath &&
|
if($file === $this->configFilePath &&
|
||||||
$filePointer === false &&
|
$filePointer === false &&
|
||||||
@!file_exists($this->configFilePath)) {
|
@!file_exists($this->configFilePath)) {
|
||||||
|
|
|
@ -43,17 +43,18 @@ class OC_Log_Owncloud {
|
||||||
$defaultLogFile = $systemConfig->getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log';
|
$defaultLogFile = $systemConfig->getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log';
|
||||||
self::$logFile = $systemConfig->getValue("logfile", $defaultLogFile);
|
self::$logFile = $systemConfig->getValue("logfile", $defaultLogFile);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Fall back to default log file if specified logfile does not exist
|
* Fall back to default log file if specified logfile does not exist
|
||||||
* and can not be created. Error suppression is required in order to
|
* and can not be created.
|
||||||
* not end up in the error handler which will try to log the error.
|
*/
|
||||||
* A better solution (compared to error suppression) would be checking
|
if (!file_exists(self::$logFile)) {
|
||||||
* !is_writable(dirname(self::$logFile)) before touch(), but
|
if(!is_writable(dirname(self::$logFile))) {
|
||||||
* is_writable() on directories used to be pretty unreliable on Windows
|
self::$logFile = $defaultLogFile;
|
||||||
* for at least some time.
|
} else {
|
||||||
*/
|
if(!touch(self::$logFile)) {
|
||||||
if (!file_exists(self::$logFile) && !@touch(self::$logFile)) {
|
self::$logFile = $defaultLogFile;
|
||||||
self::$logFile = $defaultLogFile;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue