Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
Pipeline #664 passed
...@@ -18,8 +18,8 @@ try { ...@@ -18,8 +18,8 @@ try {
$verbose = true; $verbose = true;
} }
$autocron = new \qfq\AutoCron($verbose); $autoCron = new \qfq\AutoCron($verbose);
$autocron->process(); $autoCron->process();
} catch (qfq\UserFormException $e) { } catch (qfq\UserFormException $e) {
$answer[API_MESSAGE] = $e->formatMessage(); $answer[API_MESSAGE] = $e->formatMessage();
......
...@@ -366,7 +366,6 @@ class Dirty { ...@@ -366,7 +366,6 @@ class Dirty {
// Check if the record has changed in the meantime. // Check if the record has changed in the meantime.
if ($flagCheckModifiedFirst && $this->isRecordModified($tableName, $recordId, $this->client[DIRTY_RECORD_HASH_MD5], $dummy)) { 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); 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); $lockStatus = $this->getCheckDirty($tableName, $recordId, $rcRecordDirty, $rcMsg);
......
...@@ -33,6 +33,8 @@ class Logger { ...@@ -33,6 +33,8 @@ class Logger {
return; return;
} }
$filename = self::relativeToT3Dir($filename);
if (!$handle = fopen($filename, $mode)) { if (!$handle = fopen($filename, $mode)) {
// If open fails, maybe die directory does not exist. Create it: // If open fails, maybe die directory does not exist. Create it:
...@@ -51,6 +53,22 @@ class Logger { ...@@ -51,6 +53,22 @@ class Logger {
fclose($handle); 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 * @return string
*/ */
...@@ -90,7 +108,7 @@ class Logger { ...@@ -90,7 +108,7 @@ class Logger {
$line = (is_array($data)) ? json_encode($data) : $data; $line = (is_array($data)) ? json_encode($data) : $data;
$line = '[' . $pre . '] ' . $line; $line = '[' . $pre . '] ' . $line;
if($flagNewLineFirst){ if ($flagNewLineFirst) {
$line = PHP_EOL . $line; $line = PHP_EOL . $line;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment