Commit 4f52d98b authored by Carsten  Rose's avatar Carsten Rose
Browse files

phpunit: fix problems. Revert change in...

phpunit: fix problems. Revert change in cb2e2a70: if a record lock exist, another form, with record lock mode=NONE, can't get write access to it. This is what the manual describes.
parent 9a7667f5
Pipeline #1214 passed with stage
in 1 minute and 45 seconds
......@@ -28,6 +28,31 @@ save -> dirty: action=release
deactivate dirty
save -> Alice: status=**succes**,redirect=client
== Exclusive Lock: multi user, lock on form Alice (mandatory), lock with form Bob (None) ==
Alice -> form: open page
form -> Alice: form
Bob -> form: open page
form -> Bob: form
...
Alice -> Alice: edit (first change)
Alice -> dirty: action=lock
activate dirty #FFBBBB
dirty -> Alice: status=**success**, lock_timeout=<secs>
...
Bob -> Bob: edit (first change)
Bob -> dirty: action=lock
dirty -> Bob: status=**conflict**, message=Record locked by user ...
note left: Bob: Save Button becomes disabled
...
Alice -> save: POST form
save -> dirty: lock valid?
dirty -> save: yes
save -> save: save form
save -> dirty: action=release
deactivate dirty
save -> Alice: status=**succes**,redirect=client
== Exclusive Lock: multi user, lock expired & lost ==
Alice -> form: open page
......
......@@ -163,30 +163,32 @@ class Dirty {
$formDirtyMode = $tableVars[F_DIRTY_MODE];
$rcMd5 = '';
if ($formDirtyMode == DIRTY_MODE_NONE) {
$answer = [API_STATUS => 'success', API_MESSAGE => ''];
} else {
// 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.'];
}
// 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.'];
}
// Look for already existing dirty record.
$recordDirty = $this->getRecordDirty($tableName, $recordId);
$feUser = $this->session->get(SESSION_FE_USER);
if (count($recordDirty) == 0) {
// Look for already existing dirty record.
$recordDirty = $this->getRecordDirty($tableName, $recordId);
if (count($recordDirty) == 0) {
if ($formDirtyMode == DIRTY_MODE_NONE) {
$answer = [API_STATUS => 'success', API_MESSAGE => ''];
} else {
// No dirty record found.
$feUser = $this->session->get(SESSION_FE_USER);
$answer = $this->writeDirty($this->client[SIP_SIP], $recordId, $tableVars, $feUser, $rcMd5);
} else {
$answer = $this->conflict($recordDirty, $formDirtyMode, $primaryKey);
}
} else {
$answer = $this->conflict($recordDirty, $formDirtyMode, $primaryKey);
}
return $answer;
}
/**
* Load (if exist) a DirtyRecord (lock).
*
......
......@@ -70,8 +70,8 @@ require_once(__DIR__ . '/../database/AbstractDatabaseTest.php');
*/
class DirtyTest extends AbstractDatabaseTest {
/*
* @var Sip
/**
* @var Sip Instance of class SIP
*/
protected $sip = null;
......@@ -1180,7 +1180,7 @@ class DirtyTest extends AbstractDatabaseTest {
$this->executeSQLFile(__DIR__ . '/../database/fixtures/TestFormEditor.sql', true);
$this->executeSQLFile(__DIR__ . '/../database/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/../database/fixtures/TestDirty.sql', true);
} catch (\Exception $e){
} catch (\Exception $e) {
echo $e->getMessage();
return;
}
......
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