Commit 87f88d99 authored by Marc Egger's avatar Marc Egger
Browse files

fix monitor and keep modified date when changing form fileStats

parent e0cba001
Pipeline #4053 passed with stages
in 4 minutes and 33 seconds
......@@ -943,6 +943,7 @@ const F_DIRTY_MODE = 'dirtyMode';
const F_NOTE_INTERNAL = 'noteInternal';
const F_MULTI_SQL = 'multiSql';
const F_MULTI_COL_ID = 'id';
const F_MODIFIED = 'modified';
const F_FILE_STATS = 'fileStats';
const F_SUBMIT_BUTTON_TEXT = 'submitButtonText';
......
......@@ -168,7 +168,7 @@ class Dirty {
// Check for changed record. Compute $rcMd5
$flagModified = $this->isRecordModified($tableName, $primaryKey, $recordId, $recordHashMd5, $rcMd5);
if (($recordHashMd5 != '') && $flagModified) {
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.'];
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. [1]'];
}
$feUser = $this->session->get(SESSION_FE_USER);
......@@ -237,7 +237,7 @@ class Dirty {
// Compare modified timestamp
if ($this->isRecordModified($recordDirty[DIRTY_TABLE_NAME], $primaryKey, $recordDirty[DIRTY_RECORD_ID], $recordDirty[DIRTY_RECORD_HASH_MD5], $dummy)) {
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.'];
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. [2]'];
}
if ($this->client[CLIENT_COOKIE_QFQ] == $recordDirty[DIRTY_QFQ_USER_SESSION_COOKIE]) {
......@@ -406,7 +406,7 @@ class Dirty {
// Check if the record has changed in the meantime.
if ($flagCheckModifiedFirst && $this->isRecordModified($tableName, $primaryKey, $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. [3]', ERROR_DIRTY_RECORD_MODIFIED);
}
$lockStatus = $this->getCheckDirty($tableName, $recordId, $rcRecordDirty, $rcMsg);
......@@ -439,7 +439,7 @@ class Dirty {
if ($lockStatus == LOCK_FOUND_OWNER) {
// Check if the record has changed in the meantime.
if ($this->isRecordModified($tableName, $primaryKey, $recordId, $rcRecordDirty[DIRTY_RECORD_HASH_MD5], $dummy)) {
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.'];
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. [4]'];
}
// Clear the lock
......
......@@ -172,7 +172,7 @@ class FormAsFile
*/
public static function exportForm(string $formName, Database $database, ?int $formId = null) // : void
{
list($formName, $formId, $formJson, $adjustContainerName) = self::formToJson($formName, $database, $formId);
list($formName, $formId, $formJson, $adjustContainerName, $form) = self::formToJson($formName, $database, $formId);
// backup and write file
$pathFileName = self::formPathFileName($formName, $database);
......@@ -188,7 +188,7 @@ class FormAsFile
// otherwise => Update column fileStats
} else {
$fileStats = self::formFileStatsJson($pathFileName);
list($sql, $parameterArray) = SqlQuery::updateRecord(TABLE_NAME_FORM, [F_FILE_STATS => $fileStats], $formId);
list($sql, $parameterArray) = SqlQuery::updateRecord(TABLE_NAME_FORM, [F_FILE_STATS => $fileStats, F_MODIFIED => $form[F_MODIFIED]], $formId);
$database->sql($sql, ROW_REGULAR, $parameterArray);
}
}
......@@ -680,7 +680,7 @@ class FormAsFile
* @param string $formName
* @param Database $database
* @param int|null $formId If given, $formName is ignored
* @return array [$formName, $formId, $formJson, $adjustedContainerNames > 0]
* @return array [string $formName, int $formId, string $formJson, bool ($adjustedContainerNames > 0), array $form]
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
......@@ -756,7 +756,7 @@ class FormAsFile
// add form elements and create json
$form[F_FILE_FORM_ELEMENT] = $formElements;
$formJson = json_encode($form, JSON_PRETTY_PRINT);
return array($formName, $formId, $formJson, $adjustedContainerNames > 0);
return array($formName, $formId, $formJson, $adjustedContainerNames > 0, $form);
}
/**
......@@ -786,7 +786,7 @@ class FormAsFile
while (file_exists($cwdToBackupFile)) {
$cwdToBackupFile = Path::join($cwdToBackup, $formName . '.' . date('Y-m-d_H-i-s') . ".$index.$tag.json");
$index ++;
if ($index > 100) {
if ($index > 20) {
Thrower::userFormException('Error while trying to backup form file.', 'Infinite loop.');
}
}
......
......@@ -87,7 +87,7 @@ class Monitor {
<script type="text/javascript">
$(document).ready(function () {
var getFile = new QfqNS.DisplayFile({
webworker: $webworker,
webworker: "$webworker",
filePath: "$url",
interval: $interval,
targetId: "$htmlId",
......
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