Commit b00f76bc authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixes Bug #9269 - fillStoreForm now fired two timesin API calls. The first...

Fixes Bug #9269 - fillStoreForm now fired two timesin API calls. The first time during loadFormDefinition and the second time after the STORE_TYPO3 has been faked via SIP.
parent 09734a8c
Pipeline #2435 passed with stages
in 2 minutes and 35 seconds
...@@ -367,6 +367,12 @@ class QuickFormQuery { ...@@ -367,6 +367,12 @@ class QuickFormQuery {
case FORM_REST: case FORM_REST:
$fillStoreForm = new FillStoreForm(); $fillStoreForm = new FillStoreForm();
$fillStoreForm->process($formMode); $fillStoreForm->process($formMode);
// STORE_TYPO3 has been filled: fire fillStoreVar again.
if (!empty($this->formSpec[FE_FILL_STORE_VAR])) {
$this->fillStoreVar($this->formSpec[FE_FILL_STORE_VAR]);
}
break; break;
} }
...@@ -1072,21 +1078,8 @@ class QuickFormQuery { ...@@ -1072,21 +1078,8 @@ class QuickFormQuery {
// Fire FE_FILL_STORE_VAR after the primary form record has been loaded // Fire FE_FILL_STORE_VAR after the primary form record has been loaded
if (!empty($formSpec[FE_FILL_STORE_VAR])) { if (!empty($formSpec[FE_FILL_STORE_VAR])) {
$this->fillStoreVar($formSpec[FE_FILL_STORE_VAR]);
$rows = $this->evaluate->parse($formSpec[FE_FILL_STORE_VAR], ROW_EXPECT_0_1); // unset($formSpec[FE_FILL_STORE_VAR]);
unset($formSpec[FE_FILL_STORE_VAR]);
if (is_array($rows)) {
$this->store->appendToStore($rows, STORE_VAR);
// LOG
if (!empty($form[FORM_LOG_ACTIVE])) {
Logger::logFormLine($form, "F:add to STORE_VAR", $rows);
}
} else {
if (!empty($rows)) {
throw new \UserFormException("Invalid statement for '" . FE_FILL_STORE_VAR . "': " . $formSpec[FE_FILL_STORE_VAR], ERROR_INVALID_OR_MISSING_PARAMETER);
}
}
} }
$this->formSpec = $formSpec; $this->formSpec = $formSpec;
...@@ -1130,6 +1123,36 @@ class QuickFormQuery { ...@@ -1130,6 +1123,36 @@ class QuickFormQuery {
return $formName; return $formName;
} }
/**
* If $sql selects one row, append the row to STORE_VAR.
*
* @param $sql
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
* @throws \UserReportException
*/
private function fillStoreVar($sql) {
if (empty($sql)) {
return;
}
$rows = $this->evaluate->parse($sql, ROW_EXPECT_0_1);
if (is_array($rows)) {
$this->store->appendToStore($rows, STORE_VAR);
// LOG
if (!empty($form[FORM_LOG_ACTIVE])) {
Logger::logFormLine($form, "F:add to STORE_VAR", $rows);
}
} else {
if (!empty($rows)) {
throw new \UserFormException("Invalid statement for '" . FE_FILL_STORE_VAR . "': " . $formSpec[FE_FILL_STORE_VAR], ERROR_INVALID_OR_MISSING_PARAMETER);
}
}
}
/** /**
* Depending on $sql reads FormElements to a specific container or all. Preprocess all FormElements. * Depending on $sql reads FormElements to a specific container or all. Preprocess all FormElements.
* This code is dirty: the nearly same function exists in class 'Database' - the difference is only * This code is dirty: the nearly same function exists in class 'Database' - the difference is only
......
...@@ -8,12 +8,11 @@ ...@@ -8,12 +8,11 @@
namespace IMATHUZH\Qfq\Core\Store; namespace IMATHUZH\Qfq\Core\Store;
use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser; use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray; use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Sanitize; use IMATHUZH\Qfq\Core\Helper\Sanitize;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Helper\Support; use IMATHUZH\Qfq\Core\Helper\Support;
/* /*
......
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