Commit 0c4672ff authored by Carsten  Rose's avatar Carsten Rose
Browse files

Dirty.php, FillStoreForm.php: support of different DBs implemented.

Link.php: SIP Links get automatically parameter '__dbIndexData'
Report.php: can select DB via 'dbIndex' directive (global)
AbstractBuildForm.php: dbIndexData now based on setting in Form (before on config.qfq.ini)
formEditor.sql: FormEditor update on Form 'form' and 'formElements'
parent 6b8db18b
...@@ -763,25 +763,27 @@ version, the system tables will be automatically installed or updated. ...@@ -763,25 +763,27 @@ version, the system tables will be automatically installed or updated.
System tables System tables
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
+-------------+------------+------+ +-------------+------------+------------+
| Name | Use | Note | | Name | Use | Database |
+=============+============+======+ +=============+============+============+
| Clipboard | Temporary | | | Clipboard | Temporary | QFQ |
+-------------+------------+------+ +-------------+------------+------------+
| Cron | Persistent | | | Cron | Persistent | QFQ |
+-------------+------------+------+ +-------------+------------+------------+
| Dirty | Temporary | | | Dirty | Temporary | QFQ | Data |
+-------------+------------+------+ +-------------+------------+------------+
| Form | Persistent | | | Form | Persistent | QFQ |
+-------------+------------+------+ +-------------+------------+------------+
| FormElement | Persistent | | | FormElement | Persistent | QFQ |
+-------------+------------+------+ +-------------+------------+------------+
| MailLog | Persistent | | | MailLog | Persistent | QFQ | Data |
+-------------+------------+------+ +-------------+------------+------------+
| Period | Persistent | | | Period | Persistent | Data |
+-------------+------------+------+ +-------------+------------+------------+
| Split | Temporary | | | Split | Persistent | Data |
+-------------+------------+------+ +-------------+------------+------------+
* Check Bug #5459 - support of system tables in different DBs not supported.
Multi Databases Multi Databases
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
......
...@@ -91,7 +91,8 @@ abstract class AbstractBuildForm { ...@@ -91,7 +91,8 @@ abstract class AbstractBuildForm {
$this->feSpecAction = $feSpecAction; $this->feSpecAction = $feSpecAction;
$this->feSpecNative = $feSpecNative; $this->feSpecNative = $feSpecNative;
$this->store = Store::getInstance(); $this->store = Store::getInstance();
$this->dbIndexData = $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM); // $this->dbIndexData = $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
$this->dbIndexData = $formSpec[F_DB_INDEX];
$this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM); $this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
$this->dbArray = $db; $this->dbArray = $db;
...@@ -333,8 +334,6 @@ abstract class AbstractBuildForm { ...@@ -333,8 +334,6 @@ abstract class AbstractBuildForm {
/** /**
* Build MD5 from the current record. Return HTML Input element. * Build MD5 from the current record. Return HTML Input element.
* *
* @param bool $flagWithSpan
*
* @return string * @return string
* @throws \qfq\CodeException * @throws \qfq\CodeException
* @throws \qfq\DbException * @throws \qfq\DbException
...@@ -2645,7 +2644,7 @@ abstract class AbstractBuildForm { ...@@ -2645,7 +2644,7 @@ abstract class AbstractBuildForm {
if (isset($control[SUBRECORD_COLUMN_LINK][$columnName])) { if (isset($control[SUBRECORD_COLUMN_LINK][$columnName])) {
if (!isset($link)) { if (!isset($link)) {
$link = new Link($this->sip); $link = new Link($this->sip, $this->dbIndexData);
} }
$cell = $link->renderLink($columnValue); $cell = $link->renderLink($columnValue);
} }
...@@ -2778,7 +2777,7 @@ abstract class AbstractBuildForm { ...@@ -2778,7 +2777,7 @@ abstract class AbstractBuildForm {
if (Support::isEnabled($formElement, FE_FILE_DOWNLOAD_BUTTON)) { if (Support::isEnabled($formElement, FE_FILE_DOWNLOAD_BUTTON)) {
if (is_readable($value)) { if (is_readable($value)) {
$link = new Link($this->sip); $link = new Link($this->sip, $this->dbIndexData);
$value = $link->renderLink('s|M:file|d|F:' . $value . '|' . $formElement[FE_FILE_DOWNLOAD_BUTTON]); $value = $link->renderLink('s|M:file|d|F:' . $value . '|' . $formElement[FE_FILE_DOWNLOAD_BUTTON]);
} else { } else {
// In case debugging is off: showing download button means 'never show the real pathfilename' // In case debugging is off: showing download button means 'never show the real pathfilename'
......
...@@ -796,6 +796,7 @@ const F_PARAMETER = 'parameter'; // valid for F_ and FE_ ...@@ -796,6 +796,7 @@ const F_PARAMETER = 'parameter'; // valid for F_ and FE_
// Form columns: via parameter field // Form columns: via parameter field
const F_DB_INDEX = 'dbIndex'; const F_DB_INDEX = 'dbIndex';
const DB_INDEX_DEFAULT = "1"; const DB_INDEX_DEFAULT = "1";
const PARAM_DB_INDEX_DATA = '__dbIndexData'; // Submitted via SIP to make record locking DB aware.
const F_LDAP_SERVER = 'ldapServer'; const F_LDAP_SERVER = 'ldapServer';
const F_LDAP_BASE_DN = 'ldapBaseDn'; const F_LDAP_BASE_DN = 'ldapBaseDn';
......
...@@ -319,7 +319,7 @@ class QuickFormQuery { ...@@ -319,7 +319,7 @@ class QuickFormQuery {
// Check (and release) dirtyRecord. // Check (and release) dirtyRecord.
if ($formMode === FORM_DELETE || $formMode === FORM_SAVE) { if ($formMode === FORM_DELETE || $formMode === FORM_SAVE) {
$dirty = new Dirty(); $dirty = new Dirty(false, $this->dbIndexData, $this->dbIndexQfq);
$answer = $dirty->checkDirtyAndRelease($formMode, $this->formSpec[F_RECORD_LOCK_TIMEOUT_SECONDS], $answer = $dirty->checkDirtyAndRelease($formMode, $this->formSpec[F_RECORD_LOCK_TIMEOUT_SECONDS],
$this->formSpec[F_DIRTY_MODE], $this->formSpec[F_TABLE_NAME], $recordId, true); $this->formSpec[F_DIRTY_MODE], $this->formSpec[F_TABLE_NAME], $recordId, true);
...@@ -334,7 +334,7 @@ class QuickFormQuery { ...@@ -334,7 +334,7 @@ class QuickFormQuery {
// FORM_LOAD: if there is an foreign exclusive record lock - show form in F_MODE_READONLY mode. // FORM_LOAD: if there is an foreign exclusive record lock - show form in F_MODE_READONLY mode.
if ($formMode === FORM_LOAD) { if ($formMode === FORM_LOAD) {
$dirty = new Dirty(); $dirty = new Dirty(false, $this->dbIndexData, $this->dbIndexQfq);
$recordDirty = array(); $recordDirty = array();
$rcLockFound = $dirty->getCheckDirty($this->formSpec[F_TABLE_NAME], $recordId, $recordDirty, $msg); $rcLockFound = $dirty->getCheckDirty($this->formSpec[F_TABLE_NAME], $recordId, $recordDirty, $msg);
if (($rcLockFound == LOCK_FOUND_CONFLICT || $rcLockFound == LOCK_FOUND_OWNER) && $recordDirty[F_DIRTY_MODE] == DIRTY_MODE_EXCLUSIVE) { if (($rcLockFound == LOCK_FOUND_CONFLICT || $rcLockFound == LOCK_FOUND_OWNER) && $recordDirty[F_DIRTY_MODE] == DIRTY_MODE_EXCLUSIVE) {
...@@ -347,7 +347,8 @@ class QuickFormQuery { ...@@ -347,7 +347,8 @@ class QuickFormQuery {
$build = new Delete(); $build = new Delete();
} else { } else {
$this->store->fillStoreTableDefaultColumnType($this->formSpec[F_TABLE_NAME]); $tableDefinition = $this->dbArray[$this->dbIndexData]->getTableDefinition($this->formSpec[F_TABLE_NAME]);
$this->store->fillStoreTableDefaultColumnType($tableDefinition);
switch ($this->formSpec['render']) { switch ($this->formSpec['render']) {
case 'plain': case 'plain':
...@@ -668,25 +669,30 @@ class QuickFormQuery { ...@@ -668,25 +669,30 @@ class QuickFormQuery {
unset($form[FE_FILL_STORE_VAR]); unset($form[FE_FILL_STORE_VAR]);
} }
// this is needed for filling templateGroup records with their default values
// and for evaluating variables in the Form title
$this->fillStoreWithRecord($form[F_TABLE_NAME], $recordId, STORE_RECORD);
$formSpec = $this->eval->parseArray($form);
// Setting defaults later is too late. // Setting defaults later is too late.
if (!isset($formSpec[F_DB_INDEX])) { if (empty($form[F_DB_INDEX])) {
$formSpec[F_DB_INDEX] = $this->dbIndexData; $form[F_DB_INDEX] = $this->dbIndexData;
} else {
$form[F_DB_INDEX] = $this->eval->parse($form[F_DB_INDEX]);
} }
// Some forms load/save the form data on extra defined databases. // Some forms load/save the form data on extra defined databases.
if ($this->dbIndexData != $formSpec[F_DB_INDEX]) { if ($this->dbIndexData != $form[F_DB_INDEX]) {
if (!isset($this->dbArray[$formSpec[F_DB_INDEX]])) { if (!isset($this->dbArray[$form[F_DB_INDEX]])) {
$this->dbArray[$formSpec[F_DB_INDEX]] = new Database($formSpec[F_DB_INDEX]); $this->dbArray[$form[F_DB_INDEX]] = new Database($form[F_DB_INDEX]);
} }
$this->dbIndexData = $formSpec[F_DB_INDEX]; $this->dbIndexData = $form[F_DB_INDEX];
unset($this->eval);
$this->eval = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
} }
// This is needed for filling templateGroup records with their default values
// and for evaluating variables in the Form title
$this->fillStoreWithRecord($form[F_TABLE_NAME], $recordId, STORE_RECORD);
$formSpec = $this->eval->parseArray($form);
$parameterLanguageFieldName = $this->store->getVar(SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME, STORE_SYSTEM); $parameterLanguageFieldName = $this->store->getVar(SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME, STORE_SYSTEM);
$formSpec = HelperFormElement::setLanguage($formSpec, $parameterLanguageFieldName); $formSpec = HelperFormElement::setLanguage($formSpec, $parameterLanguageFieldName);
......
...@@ -44,7 +44,7 @@ class Save { ...@@ -44,7 +44,7 @@ class Save {
$this->feSpecNative = $feSpecNative; $this->feSpecNative = $feSpecNative;
$this->feSpecNativeRaw = $feSpecNativeRaw; $this->feSpecNativeRaw = $feSpecNativeRaw;
$this->store = Store::getInstance(); $this->store = Store::getInstance();
$this->db = new Database(); $this->db = new Database($formSpec[F_DB_INDEX]);
$this->evaluate = new Evaluate($this->store, $this->db); $this->evaluate = new Evaluate($this->store, $this->db);
} }
......
...@@ -30,7 +30,10 @@ class Dirty { ...@@ -30,7 +30,10 @@ class Dirty {
/** /**
* @var Database instantiated class * @var Database instantiated class
*/ */
protected $db = null; protected $dbArray = null;
private $dbIndexData = false;
private $dbIndexQfq = false;
/** /**
* @var array * @var array
...@@ -50,17 +53,34 @@ class Dirty { ...@@ -50,17 +53,34 @@ class Dirty {
/** /**
* Init class * Init class
*/ */
public function __construct($phpUnit = false) { public function __construct($phpUnit = false, $dbIndexData = false, $dbIndexQfq = false) {
$this->session = Session::getInstance($phpUnit); $this->session = Session::getInstance($phpUnit);
$this->client = Client::getParam(); $this->client = Client::getParam();
if (!isset($this->client[DIRTY_RECORD_HASH_MD5])) { if (!isset($this->client[DIRTY_RECORD_HASH_MD5])) {
$this->client[DIRTY_RECORD_HASH_MD5] = ''; $this->client[DIRTY_RECORD_HASH_MD5] = '';
} }
// $this->store = Store::getInstance(); $this->doDbArray($dbIndexData, $dbIndexQfq);
// $dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
// $this->db = new Database($dbIndexQfq); }
$this->db = new Database();
/**
*
*/
private function doDbArray($dbIndexData, $dbIndexQfq) {
if ($dbIndexData !== false) {
$this->dbArray[$dbIndexData] = new Database($dbIndexData);
$this->dbIndexData = $dbIndexData;
}
if ($dbIndexQfq !== false) {
if ($dbIndexQfq != $dbIndexData) {
$this->dbArray[$dbIndexQfq] = new Database($dbIndexQfq);
}
$this->dbIndexQfq = $dbIndexQfq;
}
} }
/** /**
...@@ -86,10 +106,16 @@ class Dirty { ...@@ -86,10 +106,16 @@ class Dirty {
if ($recordId == 0) { if ($recordId == 0) {
// For r=0 (new) , 'dirty' will always succeed. // For r=0 (new) , 'dirty' will always succeed.
return [API_STATUS => 'success', API_MESSAGE => '']; return [API_STATUS => 'success', API_MESSAGE => ''];
} else {
$tableVars = $this->db->sql("SELECT tableName, dirtyMode, recordLockTimeoutSeconds FROM Form AS f WHERE f.name=?", ROW_EXPECT_1, [$sipVars[SIP_FORM]], "Form not found: '" . $sipVars[SIP_FORM] . "'");
} }
$this->store = Store::getInstance();
$this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
$this->dbIndexData = empty($sipVars[PARAM_DB_INDEX_DATA]) ? $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM) : $sipVars[PARAM_DB_INDEX_DATA];
$this->doDbArray($this->dbIndexData, $this->dbIndexQfq);
$tableVars = $this->dbArray[$this->dbIndexQfq]->sql("SELECT tableName, dirtyMode, recordLockTimeoutSeconds FROM Form AS f WHERE f.name=?", ROW_EXPECT_1, [$sipVars[SIP_FORM]], "Form not found: '" . $sipVars[SIP_FORM] . "'");
switch ($this->client[API_LOCK_ACTION]) { switch ($this->client[API_LOCK_ACTION]) {
case API_LOCK_ACTION_LOCK: case API_LOCK_ACTION_LOCK:
case API_LOCK_ACTION_EXTEND: case API_LOCK_ACTION_EXTEND:
...@@ -158,7 +184,7 @@ class Dirty { ...@@ -158,7 +184,7 @@ class Dirty {
*/ */
private function getRecordDirty($tableName, $recordId) { private function getRecordDirty($tableName, $recordId) {
$recordDirty = $this->db->sql("SELECT * FROM Dirty AS d WHERE d.tableName LIKE ? AND recordId=? ", $recordDirty = $this->dbArray[$this->dbIndexQfq]->sql("SELECT * FROM Dirty AS d WHERE d.tableName LIKE ? AND recordId=? ",
ROW_EXPECT_0_1, [$tableName, $recordId]); ROW_EXPECT_0_1, [$tableName, $recordId]);
// Check if the record is timed out - owner doesn't matter. // Check if the record is timed out - owner doesn't matter.
...@@ -229,11 +255,11 @@ class Dirty { ...@@ -229,11 +255,11 @@ class Dirty {
$tableName = $tableVars[F_TABLE_NAME]; $tableName = $tableVars[F_TABLE_NAME];
$formDirtyMode = $tableVars[F_DIRTY_MODE]; $formDirtyMode = $tableVars[F_DIRTY_MODE];
$record = $this->db->sql("SELECT * FROM $tableName WHERE id=?", ROW_EXPECT_1, [$recordId], "Record to lock not found."); $record = $this->dbArray[$this->dbIndexData]->sql("SELECT * FROM $tableName WHERE id=?", ROW_EXPECT_1, [$recordId], "Record to lock not found.");
$expire = date('Y-m-d H:i:s', strtotime("+" . $tableVars[F_RECORD_LOCK_TIMEOUT_SECONDS] . " seconds")); $expire = date('Y-m-d H:i:s', strtotime("+" . $tableVars[F_RECORD_LOCK_TIMEOUT_SECONDS] . " seconds"));
// Write 'dirty' record // Write 'dirty' record
$this->db->sql("INSERT INTO Dirty (`sip`, `tableName`, `recordId`, `expire`, `recordHashMd5`, `feUser`, `qfqUserSessionCookie`, `dirtyMode`, `remoteAddress`, `created`) " . $this->dbArray[$this->dbIndexQfq]->sql("INSERT INTO Dirty (`sip`, `tableName`, `recordId`, `expire`, `recordHashMd5`, `feUser`, `qfqUserSessionCookie`, `dirtyMode`, `remoteAddress`, `created`) " .
"VALUES ( ?,?,?,?,?,?,?,?,?,? )", ROW_REGULAR, "VALUES ( ?,?,?,?,?,?,?,?,?,? )", ROW_REGULAR,
[$s, $tableName, $recordId, $expire, $recordHashMd5, $feUser, $this->client[CLIENT_COOKIE_QFQ], $formDirtyMode, [$s, $tableName, $recordId, $expire, $recordHashMd5, $feUser, $this->client[CLIENT_COOKIE_QFQ], $formDirtyMode,
$this->client[CLIENT_REMOTE_ADDRESS], date('YmdHis')]); $this->client[CLIENT_REMOTE_ADDRESS], date('YmdHis')]);
...@@ -260,7 +286,7 @@ class Dirty { ...@@ -260,7 +286,7 @@ class Dirty {
return false; // If there is no recordHashMd5, the check is not possible. Always return 'not modified' (=ok) return false; // If there is no recordHashMd5, the check is not possible. Always return 'not modified' (=ok)
} }
$record = $this->db->sql("SELECT * FROM $tableName WHERE id=?", ROW_EXPECT_1, [$recordId], "Record to lock not found."); $record = $this->dbArray[$this->dbIndexData]->sql("SELECT * FROM $tableName WHERE id=?", ROW_EXPECT_1, [$recordId], "Record to lock not found.");
$rcMd5 = OnArray::getMd5($record); $rcMd5 = OnArray::getMd5($record);
...@@ -410,7 +436,7 @@ class Dirty { ...@@ -410,7 +436,7 @@ class Dirty {
*/ */
private function deleteDirtyRecord($recordDirtyId) { private function deleteDirtyRecord($recordDirtyId) {
$cnt = $this->db->sql('DELETE FROM Dirty WHERE id=? LIMIT 1', ROW_REGULAR, [$recordDirtyId]); $cnt = $this->dbArray[$this->dbIndexQfq]->sql('DELETE FROM Dirty WHERE id=? LIMIT 1', ROW_REGULAR, [$recordDirtyId]);
if ($cnt != 1) { if ($cnt != 1) {
throw new CodeException("Failed to delete dirty record id=" . $recordDirtyId, ERROR_DIRTY_DELETE_RECORD); throw new CodeException("Failed to delete dirty record id=" . $recordDirtyId, ERROR_DIRTY_DELETE_RECORD);
} }
......
...@@ -146,6 +146,8 @@ class Link { ...@@ -146,6 +146,8 @@ class Link {
*/ */
private $thumbnail = null; private $thumbnail = null;
private $dbIndexData = false;
private $phpUnit; private $phpUnit;
private $renderControl = array(); private $renderControl = array();
// private $linkClassSelector = array(TOKEN_CLASS_INTERNAL => "internal ", TOKEN_CLASS_EXTERNAL => "external "); // private $linkClassSelector = array(TOKEN_CLASS_INTERNAL => "internal ", TOKEN_CLASS_EXTERNAL => "external ");
...@@ -235,7 +237,7 @@ class Link { ...@@ -235,7 +237,7 @@ class Link {
* @param Sip $sip * @param Sip $sip
* @param bool $phpUnit * @param bool $phpUnit
*/ */
public function __construct(Sip $sip, $phpUnit = false) { public function __construct(Sip $sip, $dbIndexData = DB_INDEX_DEFAULT, $phpUnit = false) {
$this->phpUnit = $phpUnit; $this->phpUnit = $phpUnit;
if ($phpUnit) { if ($phpUnit) {
...@@ -247,7 +249,7 @@ class Link { ...@@ -247,7 +249,7 @@ class Link {
$this->cssLinkClassInternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_INTERNAL, STORE_SYSTEM); $this->cssLinkClassInternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_INTERNAL, STORE_SYSTEM);
$this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM); $this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM);
$this->ttContentUid = $this->store->getVar(TYPO3_TT_CONTENT_UID, STORE_TYPO3); $this->ttContentUid = $this->store->getVar(TYPO3_TT_CONTENT_UID, STORE_TYPO3);
$this->dbIndexData = $dbIndexData;
/* /*
* mode: * mode:
* 0: no output * 0: no output
...@@ -787,6 +789,15 @@ class Link { ...@@ -787,6 +789,15 @@ class Link {
if ($vars[NAME_MAIL] === '') { if ($vars[NAME_MAIL] === '') {
if ($vars[NAME_SIP] === "1") {
// Only for SIP encoded Links: append the current $dbIndexData to make record locking work even for records in dbIndexQfq
if ($vars[NAME_URL_PARAM] != '') {
$vars[NAME_URL_PARAM] .= '&';
}
$vars[NAME_URL_PARAM] .= PARAM_DB_INDEX_DATA . '=' . $this->dbIndexData;
}
if (substr($vars[NAME_URL], 0, 1) === '?') { if (substr($vars[NAME_URL], 0, 1) === '?') {
$vars[NAME_URL] = INDEX_PHP . $vars[NAME_URL]; $vars[NAME_URL] = INDEX_PHP . $vars[NAME_URL];
} }
...@@ -795,6 +806,7 @@ class Link { ...@@ -795,6 +806,7 @@ class Link {
$urlNParam = Support::concatUrlParam($vars[NAME_URL] . $vars[NAME_PAGE], $vars[NAME_URL_PARAM]); $urlNParam = Support::concatUrlParam($vars[NAME_URL] . $vars[NAME_PAGE], $vars[NAME_URL_PARAM]);
if ($vars[NAME_SIP] === "1") { if ($vars[NAME_SIP] === "1") {
$paramArray = $this->sip->queryStringToSip($urlNParam, RETURN_ARRAY); $paramArray = $this->sip->queryStringToSip($urlNParam, RETURN_ARRAY);
$urlNParam = $paramArray['_url']; $urlNParam = $paramArray['_url'];
......
...@@ -84,6 +84,7 @@ class Report { ...@@ -84,6 +84,7 @@ class Report {
*/ */
private $db = null; private $db = null;
private $dbIndexData = false;
/** /**
* @var Thumbnail * @var Thumbnail
*/ */
...@@ -126,8 +127,6 @@ class Report { ...@@ -126,8 +127,6 @@ class Report {
$_SERVER['REQUEST_URI'] = 'localhost'; $_SERVER['REQUEST_URI'] = 'localhost';
} }
$this->link = new Link($this->sip, $phpUnit);
$this->store = Store::getInstance(); $this->store = Store::getInstance();
$this->showDebugInfoFlag = (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM))); $this->showDebugInfoFlag = (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM)));
...@@ -151,11 +150,13 @@ class Report { ...@@ -151,11 +150,13 @@ class Report {
$this->pageDefaults[DEFAULT_BOOTSTRAP_BUTTON]["pages"] = TOKEN_BOOTSTRAP_BUTTON; $this->pageDefaults[DEFAULT_BOOTSTRAP_BUTTON]["pages"] = TOKEN_BOOTSTRAP_BUTTON;
// Default should already set in QuickFormQuery() Constructor // Default should already set in QuickFormQuery() Constructor
$dbIndex = $this->store->getVar(TOKEN_DB_INDEX, STORE_TYPO3 . STORE_EMPTY); $this->dbIndexData = $this->store->getVar(TOKEN_DB_INDEX, STORE_TYPO3 . STORE_EMPTY);
$this->db = new Database($dbIndex); $this->db = new Database($this->dbIndexData);
$this->variables = new Variables($eval, $t3data["uid"]); $this->variables = new Variables($eval, $t3data["uid"]);
$this->link = new Link($this->sip, $this->dbIndexData, $phpUnit);
// Set static values, which won't change during this run. // Set static values, which won't change during this run.
$this->fr_error["pid"] = isset($this->variables->resultArray['global.']['page_id']) ? $this->variables->resultArray['global.']['page_id'] : 0; $this->fr_error["pid"] = isset($this->variables->resultArray['global.']['page_id']) ? $this->variables->resultArray['global.']['page_id'] : 0;
$this->fr_error["uid"] = $t3data['uid']; $this->fr_error["uid"] = $t3data['uid'];
......
...@@ -22,9 +22,12 @@ class FillStoreForm { ...@@ -22,9 +22,12 @@ class FillStoreForm {
private $store = null; private $store = null;
/** /**
* @var Database * @var Database[]
*/ */
private $db = null; private $dbArray = array();
private $dbIndexData = false;
private $dbIndexQfq = false;
/** /**
* @var array * @var array
...@@ -42,9 +45,20 @@ class FillStoreForm { ...@@ -42,9 +45,20 @@ class FillStoreForm {
public function __construct() { public function __construct() {
$this->store = Store::getInstance(); $this->store = Store::getInstance();
$this->db = new Database(); $this->dbIndexData = $this->store->getVar(PARAM_DB_INDEX_DATA, STORE_SIP);
if ($this->dbIndexData === false) {
$this->dbIndexData = DB_INDEX_DEFAULT; // Fallback for FORMs which are not called via SIP;
}
$this->dbArray[$this->dbIndexData] = new Database($this->dbIndexData);
$this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
if ($this->dbIndexQfq != $this->dbIndexData) {
$this->dbArray[$this->dbIndexQfq] = new Database($this->dbIndexQfq);
}
$this->feSpecNative = $this->loadFormElementsBasedOnSIP(); $this->feSpecNative = $this->loadFormElementsBasedOnSIP();
$this->evaluate = new Evaluate($this->store, $this->db); $this->evaluate = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
} }
...@@ -63,11 +77,11 @@ class FillStoreForm { ...@@ -63,11 +77,11 @@ class FillStoreForm {
// Preparation for Log, Debug // Preparation for Log, Debug
$this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM); $this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM);
$feSpecNative = $this->db->sql(SQL_FORM_ELEMENT_SIMPLE_ALL_CONTAINER, ROW_EXPECT_GE_1, [$formName], $feSpecNative = $this->dbArray[$this->dbIndexQfq]->sql(SQL_FORM_ELEMENT_SIMPLE_ALL_CONTAINER, ROW_EXPECT_GE_1, [$formName],
'Form or FormElements not found: ' . ERROR_FORM_NOT_FOUND); 'Form or FormElements not found: ' . ERROR_FORM_NOT_FOUND);
HelperFormElement::explodeParameterInArrayElements($feSpecNative, FE_PARAMETER); HelperFormElement::explodeParameterInArrayElements($feSpecNative, FE_PARAMETER);
$feSpecTemplateGroup = $this->db->sql(SQL_FORM_ELEMENT_CONTAINER_TEMPLATE_GROUP, ROW_REGULAR, [$formName]); $feSpecTemplateGroup = $this->dbArray[$this->dbIndexQfq]->sql(SQL_FORM_ELEMENT_CONTAINER_TEMPLATE_GROUP, ROW_REGULAR, [$formName]);
HelperFormElement::explodeParameterInArrayElements($feSpecTemplateGroup, FE_PARAMETER); HelperFormElement::explodeParameterInArrayElements($feSpecTemplateGroup, FE_PARAMETER);
$feSpecNative = $this->expandTemplateGroupFormElement($feSpecTemplateGroup, $feSpecNative); $feSpecNative = $this->expandTemplateGroupFormElement($feSpecTemplateGroup, $feSpecNative);
......
...@@ -760,14 +760,12 @@ class Store { ...@@ -760,14 +760,12 @@ class Store {
/** /**
* Fills STORE_TABLE_DEFAULT and STORE_TABLE_COLUMN_TYPES * Fills STORE_TABLE_DEFAULT and STORE_TABLE_COLUMN_TYPES
* *
* @param $tableName * @param array $tableDefinition
* *
* @throws CodeException * @throws CodeException
* @throws UserFormException
*/ */
public static function fillStoreTableDefaultColumnType($tableName) { public static function fillStoreTableDefaultColumnType(array $tableDefinition) {
$db = new qfq\Database();
$tableDefinition = $db->getTableDefinition($tableName);
self::setStore(array_column($tableDefinition, 'Default', 'Field'), STORE_TABLE_DEFAULT, true); self::setStore(array_column($tableDefinition, 'Default', 'Field'), STORE_TABLE_DEFAULT, true);
self::setStore(array_column($tableDefinition, 'Type', 'Field'), STORE_TABLE_COLUMN_TYPES, true); self::setStore(array_column($tableDefinition, 'Type', 'Field'), STORE_TABLE_COLUMN_TYPES, true);
......
...@@ -187,8 +187,8 @@ WHERE FIND_IN_SET(Form.name, 'form,formElement,copyForm,cron') > 0; ...@@ -187,8 +187,8 @@ WHERE FIND_IN_SET(Form.name, 'form,formElement,copyForm,cron') > 0;