Commit e11b5ae6 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Logger.php: qfq.log has been saved in wrong directory, if there was an error during an API call.

parent 979bad8d
Pipeline #664 passed with stage
in 1 minute and 32 seconds
......@@ -18,8 +18,8 @@ try {
$verbose = true;
}
$autocron = new \qfq\AutoCron($verbose);
$autocron->process();
$autoCron = new \qfq\AutoCron($verbose);
$autoCron->process();
} catch (qfq\UserFormException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
......
......@@ -366,7 +366,6 @@ class Dirty {
// Check if the record has changed in the meantime.
if ($flagCheckModifiedFirst && $this->isRecordModified($tableName, $recordId, $this->client[DIRTY_RECORD_HASH_MD5], $dummy)) {
throw new UserFormException ('The record has been modified in the meantime. Please reload the form, edit and save again.', ERROR_DIRTY_RECORD_MODIFIED);
// return [API_STATUS => API_ANSWER_STATUS_CONFLICT, API_MESSAGE => 'The record has been modified in the meantime. Please reload the form, edit and save again.'];
}
$lockStatus = $this->getCheckDirty($tableName, $recordId, $rcRecordDirty, $rcMsg);
......
......@@ -33,6 +33,8 @@ class Logger {
return;
}
$filename = self::relativeToT3Dir($filename);
if (!$handle = fopen($filename, $mode)) {
// If open fails, maybe die directory does not exist. Create it:
......@@ -51,6 +53,22 @@ class Logger {
fclose($handle);
}
/**
* In case $filename is not absolute and if we're in the API directory: Check if we're in api - update relative filename
*
* @return string
*/
private static function relativeToT3Dir($filename) {
if (isset($filename[0]) && $filename[0] != '/') {
if (strpos(getcwd(), '/qfq/qfq/api') !== false) {
return ('../../../../../' . $filename);
}
}
return $filename;
}
/**
* @return string
*/
......@@ -90,7 +108,7 @@ class Logger {
$line = (is_array($data)) ? json_encode($data) : $data;
$line = '[' . $pre . '] ' . $line;
if($flagNewLineFirst){
if ($flagNewLineFirst) {
$line = PHP_EOL . $line;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment