fixed questionnaire revision bug
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
2026-07-18 13:51:01 +02:00
parent 06d53c564e
commit 63aad5d9e9
3 changed files with 63 additions and 1 deletions

View File

@ -197,10 +197,17 @@ case 'PUT':
$oldKey = qdb_question_key($oldCfg, $row['defaultText']);
$oldSymptoms = json_encode($oldCfg['symptoms'] ?? [], JSON_UNESCAPED_UNICODE);
$newSymptoms = json_encode($config['symptoms'] ?? [], JSON_UNESCAPED_UNICODE);
// Notes live in configJson and are exported as noteBeforeKey/noteAfterKey + translations.
// App sync skips detail re-download when structureRevision is unchanged, so note-only
// (and other app-visible config) edits must bump the revision.
$oldNotes = trim((string)($oldCfg['noteBefore'] ?? '')) . "\0" . trim((string)($oldCfg['noteAfter'] ?? ''));
$newNotes = trim((string)($config['noteBefore'] ?? '')) . "\0" . trim((string)($config['noteAfter'] ?? ''));
$structuralChange = ($type !== (string)$row['type'])
|| ($req !== (int)$row['isRequired'])
|| ($questionKey !== $oldKey)
|| ($newSymptoms !== $oldSymptoms);
|| ($newSymptoms !== $oldSymptoms)
|| ($oldNotes !== $newNotes)
|| (json_encode($config, JSON_UNESCAPED_UNICODE) !== json_encode($oldCfg, JSON_UNESCAPED_UNICODE));
if ((int)($row['retiredAt'] ?? 0) > 0) {
qdb_discard($tmpDb, $lockFp);
json_error('INVALID_FIELD', 'Cannot edit a retired question', 400);