Commit 324a1ad3 authored by Carsten  Rose's avatar Carsten Rose

Fix that saving a record with no FE, always update the modified column of the primary record.

parent 15439f12
Pipeline #2475 passed with stages
in 2 minutes and 43 seconds
......@@ -9,16 +9,16 @@
namespace IMATHUZH\Qfq\Core;
use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Form\FormAction;
use IMATHUZH\Qfq\Core\Helper\HelperFile;
use IMATHUZH\Qfq\Core\Helper\HelperFormElement;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Sanitize;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Store\FillStoreForm;
use IMATHUZH\Qfq\Core\Store\Sip;
use IMATHUZH\Qfq\Core\Store\Store;
use IMATHUZH\Qfq\Core\Store\FillStoreForm;
use IMATHUZH\Qfq\Core\Form\FormAction;
/**
* Class Save
......@@ -123,12 +123,17 @@ class Save {
}
$fillStoreForm = new FillStoreForm();
$storeVarBase = $this->store->getStore(STORE_VAR);
foreach ($parentRecords as $row) {
$row[F_MULTI_COL_ID] = $row[$idName]; // In case '_id' is used, both '_id' and 'id' should be accessible.
// Always start with a clean STORE_VAR
$this->store->setStore($storeVarBase, STORE_VAR, true);
$this->store->setStore($row, STORE_PARENT_RECORD, true);
$this->store->setVar(F_MULTI_COL_ID, $row[$idName], STORE_PARENT_RECORD); // In case '_id' is used, both '_id' and 'id' should be accessible.
$record = $this->db->sql('SELECT * FROM `' . $this->formSpec[F_TABLE_NAME] . '` WHERE id=' . $row[F_MULTI_COL_ID], ROW_EXPECT_1);
$record = $this->db->sql('SELECT * FROM `' . $this->formSpec[F_TABLE_NAME] . '` WHERE id=' . $row[$idName], ROW_EXPECT_1);
$this->store->setStore($record, STORE_RECORD, true);
// Fake current recordId
......@@ -277,7 +282,7 @@ class Save {
}
if ($columnModified && !isset($newValues[COLUMN_MODIFIED])) {
if ($columnModified && !empty($newValues) && !isset($newValues[COLUMN_MODIFIED])) {
$newValues[COLUMN_MODIFIED] = date('YmdHis');
}
......@@ -288,7 +293,9 @@ class Save {
$rc = $this->insertRecord($this->formSpec[F_TABLE_NAME], $newValues);
} else {
$this->updateRecord($this->formSpec[F_TABLE_NAME], $newValues, $recordId, $this->formSpec[F_PRIMARY_KEY]);
if (!empty($newValues)) {
$this->updateRecord($this->formSpec[F_TABLE_NAME], $newValues, $recordId, $this->formSpec[F_PRIMARY_KEY]);
}
$rc = $recordId;
}
......
Markdown is supported
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