Commit 2c66362d authored by Carsten  Rose's avatar Carsten Rose
Browse files

Implemented setting 'db_?_xxx' in config.qfq.ini and QuickFormQuery.php and...

Implemented setting 'db_?_xxx' in config.qfq.ini and QuickFormQuery.php and other files. Open: saving in  DB_INDEX_QFQ.
parent 657e0885
......@@ -2,10 +2,18 @@
;
; Save this file as: <Documentroot>/typo3conf/config.qfq.ini
DB_USER = <DBUSER>
DB_SERVER = <DBSERVER>
DB_PASSWORD = <DBPW>
DB_NAME = <DB>
DB_1_USER = <DBUSER>
DB_1_SERVER = <DBSERVER>
DB_1_PASSWORD = <DBPW>
DB_1_NAME = <DB>
;DB_2_USER = <DBUSER>
;DB_2_SERVER = <DBSERVER>
;DB_2_PASSWORD = <DBPW>
;DB_2_NAME = <DB>
DB_INDEX_DATA = 1
DB_INDEX_QFQ = 1
DB_INIT = set names utf8
......
......@@ -70,6 +70,13 @@ abstract class AbstractBuildForm {
*/
private $bodytextParser = null;
/**
* @var Array of Database instantiated class
*/
protected $dbArray = array();
protected $dbIndexData = false;
protected $dbIndexQfq = false;
/**
* AbstractBuildForm constructor.
*
......@@ -77,13 +84,16 @@ abstract class AbstractBuildForm {
* @param array $feSpecAction
* @param array $feSpecNative
*/
public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative) {
public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative, array $db) {
$this->formSpec = $formSpec;
$this->feSpecAction = $feSpecAction;
$this->feSpecNative = $feSpecNative;
$this->store = Store::getInstance();
$this->db = new Database();
$this->evaluate = new Evaluate($this->store, $this->db);
$this->dbIndexData = $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
$this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
$this->dbArray = $db;
$this->evaluate = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
$this->showDebugInfoFlag = Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM));
$this->sip = $this->store->getSipInstance();
......@@ -188,7 +198,7 @@ abstract class AbstractBuildForm {
if ($this->formSpec['multiMode'] !== 'none') {
$parentRecords = $this->db->sql($this->formSpec['multiSql']);
$parentRecords = $this->dbArray[$this->dbIndexQfq]->sql($this->formSpec['multiSql']);
foreach ($parentRecords as $row) {
$this->store->setStore($row, STORE_PARENT_RECORD, true);
$jsonTmp = array();
......@@ -348,7 +358,7 @@ abstract class AbstractBuildForm {
$record = array();
if ($recordId != 0) {
$record = $this->db->sql("SELECT * FROM $tableName WHERE id=?", ROW_EXPECT_1, [$recordId], "Record to load not found.");
$record = $this->dbArray[$this->dbIndexData]->sql("SELECT * FROM $tableName WHERE id=?", ROW_EXPECT_1, [$recordId], "Record to load not found.");
}
return OnArray::getMd5($record);
......@@ -432,7 +442,7 @@ abstract class AbstractBuildForm {
*/
public function getEncType() {
$result = $this->db->sql("SELECT id FROM FormElement AS fe WHERE fe.formId=? AND fe.type='upload' LIMIT 1", ROW_REGULAR, [$this->formSpec['id']], 'Look for Formelement.type="upload"');
$result = $this->dbArray[$this->dbIndexQfq]->sql("SELECT id FROM FormElement AS fe WHERE fe.formId=? AND fe.type='upload' LIMIT 1", ROW_REGULAR, [$this->formSpec['id']], 'Look for Formelement.type="upload"');
return (count($result) === 1) ? 'multipart/form-data' : 'application/x-www-form-urlencoded';
......@@ -497,15 +507,13 @@ abstract class AbstractBuildForm {
$storeUseDefault = STORE_USE_DEFAULT, $mode = FORM_LOAD) {
$html = '';
// $html .= $this->buildRecordHashMd5();
// The following 'FormElement.parameter' will never be used during load (fe.type='upload'). FE_PARAMETER has been already expanded.
$skip = [FE_SQL_UPDATE, FE_SQL_INSERT, FE_SQL_DELETE, FE_SQL_AFTER, FE_SQL_BEFORE, FE_PARAMETER];
// get current data record
if ($recordId > 0 && $this->store->getVar('id', STORE_RECORD) === false) {
$tableName = $this->formSpec[F_TABLE_NAME];
$row = $this->db->sql("SELECT * FROM $tableName WHERE id = ?", ROW_EXPECT_1,
$row = $this->dbArray[$this->dbIndexData]->sql("SELECT * FROM $tableName WHERE id = ?", ROW_EXPECT_1,
array($recordId), "Form '" . $this->formSpec[F_NAME] . "' failed to load record '$recordId' from table '" .
$this->formSpec[F_TABLE_NAME] . "'.");
$this->store->setStore($row, STORE_RECORD);
......@@ -2585,7 +2593,7 @@ abstract class AbstractBuildForm {
* @throws DbException
*/
private function getFormTable($formName) {
$row = $this->db->sql("SELECT " . F_TABLE_NAME . " FROM Form AS f WHERE f.name = ?", ROW_EXPECT_0_1, [$formName]);
$row = $this->dbArray[$this->dbIndexQfq]->sql("SELECT " . F_TABLE_NAME . " FROM Form AS f WHERE f.name = ?", ROW_EXPECT_0_1, [$formName]);
if (isset($row[F_TABLE_NAME])) {
return $row[F_TABLE_NAME];
}
......@@ -3291,7 +3299,7 @@ abstract class AbstractBuildForm {
$html .= $this->wrap[WRAP_SETUP_IN_FIELDSET][WRAP_SETUP_START];
// child FE's
$this->feSpecNative = $this->db->getNativeFormElements(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER,
$this->feSpecNative = $this->dbArray[$this->dbIndexQfq]->getNativeFormElements(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER,
['yes', $this->formSpec["id"], 'native,container', $formElement[FE_ID]], $this->formSpec);
$html .= $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE_SUBRECORD, 0, $json);
......@@ -3381,7 +3389,7 @@ EOT;
EOT;
// child FE's
$this->feSpecNative = $this->db->getNativeFormElements(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER,
$this->feSpecNative = $this->dbArray[$this->dbIndexQfq]->getNativeFormElements(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER,
['yes', $this->formSpec[F_ID], 'native,container', $formElement[FE_ID]], $this->formSpec);
// Count defined FormElements in the current templateGroup
......
......@@ -27,17 +27,11 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @param array $formSpec
* @param array $feSpecAction
* @param array $feSpecNative
* @param array $db Array of 'Database' instances
*/
public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative) {
parent::__construct($formSpec, $feSpecAction, $feSpecNative);
public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative, array $db) {
parent::__construct($formSpec, $feSpecAction, $feSpecNative, $db);
$this->isFirstPill = true;
// Set some defaults
// if (!isset($this->formSpec['class'])) {
// $this->formSpec['class'] = 'container';
// }
// $this->formSpec['class'] = 'none';
}
/**
......@@ -200,7 +194,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
break;
case 'formElement':
if (false !== ($formId = $this->store->getVar(FE_FORM_ID, STORE_SIP . STORE_RECORD))) {
$row = $this->db->sql("SELECT f.name FROM Form AS f WHERE id=" . $formId, ROW_EXPECT_1);
$row = $this->dbArray[$this->dbIndexQfq]->sql("SELECT f.name FROM Form AS f WHERE id=" . $formId, ROW_EXPECT_1);
$form = current($row);
}
break;
......@@ -569,7 +563,7 @@ EOF;
$tmpStore = $this->feSpecNative;
// child FE's
$this->feSpecNative = $this->db->getNativeFormElements(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER,
$this->feSpecNative = $this->dbArray[$this->dbIndexQfq]->getNativeFormElements(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER,
['yes', $this->formSpec["id"], 'native,container', $formElement['id']], $this->formSpec);
$html = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE_SUBRECORD, 0, $json);
......
......@@ -352,6 +352,10 @@ const SYSTEM_DB_PASSWORD = 'DB_PASSWORD';
const SYSTEM_DB_NAME = 'DB_NAME';
const SYSTEM_DB_NAME_TEST = 'DB_NAME_TEST';
const SYSTEM_DB_INIT = 'DB_INIT';
const SYSTEM_DB_INDEX_DATA = "DB_INDEX_DATA";
const SYSTEM_DB_INDEX_QFQ = "DB_INDEX_QFQ";
const SYSTEM_SQL_LOG = 'SQL_LOG'; // Logging to file
const SYSTEM_SQL_LOG_FILE = '../../sql.log';
const SYSTEM_SQL_LOG_MODE = 'SQL_LOG_MODE'; // Mode, which statements to log.
......@@ -524,11 +528,6 @@ const VAR_FILE_DESTINATION = 'fileDestination';
const VAR_SLAVE_ID = ACTION_KEYWORD_SLAVE_ID;
const VAR_FILENAME = 'filename'; // Original filename of an uploaded file.
// PHP class DB can operate in these modes
const MODE_DB_REGULAR = 'regular';
const MODE_DB_NO_LOG = 'noLog';
// PHP class Typeahead
const TYPEAHEAD_API_QUERY = 'query'; // Name of parameter in API call of typeahead.php?query=...&s=... - See also FE_TYPE_AHEAD_SQL
const TYPEAHEAD_API_PREFETCH = 'prefetch'; // Name of parameter in API call of typeahead.php?prefetch=...&s=... - See also FE_TYPE_AHEAD_SQL
......
......@@ -69,9 +69,9 @@ class QuickFormQuery {
protected $store = null;
/**
* @var Database instantiated class
* @var Array of Database instantiated class
*/
protected $db = null;
protected $dbArray = array();
/**
* @var Evaluate instantiated class
......@@ -96,6 +96,9 @@ class QuickFormQuery {
*/
private $session = null;
private $dbIndexData = false;
private $dbIndexQfq = false;
/*
* TODO:
* Preparation: setup logging, database access, record locking
......@@ -150,12 +153,17 @@ class QuickFormQuery {
$this->store = Store::getInstance($bodytext, $phpUnit);
$this->store->setVar(TYPO3_TT_CONTENT_UID, $t3data[T3DATA_UID], STORE_TYPO3);
$this->db = new Database();
$this->dbIndexData = $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
$this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
$this->dbArray[$this->dbIndexData] = new Database($this->dbIndexData);
if ($this->dbIndexData != $this->dbIndexQfq) {
$this->dbArray[$this->dbIndexQfq] = new Database($this->dbIndexQfq);
}
$this->eval = new Evaluate($this->store, $this->db);
$this->eval = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
$dbUpdate = $this->store->getVar(SYSTEM_DB_UPDATE, STORE_SYSTEM);
$updateDb = new DatabaseUpdate($this->db);
$updateDb = new DatabaseUpdate($this->dbArray[$this->dbIndexQfq]);
$updateDb->checkNupdate($dbUpdate);
$this->store->systemStoreUpdate(); // Do this after the DB-update
......@@ -330,14 +338,14 @@ class QuickFormQuery {
$build = new BuildFormTable($this->formSpec, $this->feSpecAction, $this->feSpecNative);
break;
case 'bootstrap':
$build = new BuildFormBootstrap($this->formSpec, $this->feSpecAction, $this->feSpecNative);
$build = new BuildFormBootstrap($this->formSpec, $this->feSpecAction, $this->feSpecNative, $this->dbArray);
break;
default:
throw new CodeException("This statement should never be reached", ERROR_CODE_SHOULD_NOT_HAPPEN);
}
}
$formAction = new FormAction($this->formSpec, $this->db, $this->phpUnit);
$formAction = new FormAction($this->formSpec, $this->dbArray[$this->dbIndexQfq], $this->phpUnit);
switch ($formMode) {
case FORM_LOAD:
$formAction->elements($recordId, $this->feSpecAction, FE_TYPE_BEFORE_LOAD);
......@@ -525,7 +533,7 @@ class QuickFormQuery {
# select clipboard records
$sql = "SELECT c.idSrc as id, c.xId FROM Clipboard AS c WHERE c.cookie='$cookieQfq' AND c.formIdPaste=$formId ORDER BY c.id";
$arrClipboard = $this->db->sql($sql);
$arrClipboard = $this->dbArray[$this->dbIndexQfq]->sql($sql);
// Process clipboard records.
foreach ($arrClipboard AS $srcIdRecord) {
......@@ -604,8 +612,8 @@ class QuickFormQuery {
return false;
}
if (!$this->db->existTable('Form')) {
throw new UserFormException("Table 'Form' not found", ERROR_MISSING_TABLE);
if (!$this->dbArray[$this->dbIndexQfq]->existTable(TABLE_NAME_FORM)) {
throw new UserFormException("Table '" . TABLE_NAME_FORM . "' not found", ERROR_MISSING_TABLE);
}
// Preparation for Log, Debug
......@@ -620,7 +628,7 @@ class QuickFormQuery {
// Load form
$constant = F_NAME; // PhpStorm complains if the constant is directly defined in the string below
$form = $this->db->sql("SELECT * FROM Form AS f WHERE f.$constant LIKE ? AND f.deleted='no'", ROW_EXPECT_1,
$form = $this->dbArray[$this->dbIndexQfq]->sql("SELECT * FROM Form AS f WHERE f.$constant LIKE ? AND f.deleted='no'", ROW_EXPECT_1,
[$formName], 'Form not found or multiple forms with the same name.');
$form = $this->modeCleanFormConfig($mode, $form);
......@@ -652,7 +660,7 @@ class QuickFormQuery {
$this->store->setVar(SYSTEM_FORM_ELEMENT, '', STORE_SYSTEM);
// FE: Action
$this->feSpecAction = $this->db->sql(SQL_FORM_ELEMENT_ALL_CONTAINER, ROW_REGULAR, ['no', $this->formSpec["id"], 'action']);
$this->feSpecAction = $this->dbArray[$this->dbIndexQfq]->sql(SQL_FORM_ELEMENT_ALL_CONTAINER, ROW_REGULAR, ['no', $this->formSpec["id"], 'action']);
HelperFormElement::explodeParameterInArrayElements($this->feSpecAction, FE_PARAMETER);
// FE: Native & Container
......@@ -661,7 +669,7 @@ class QuickFormQuery {
switch ($mode) {
case FORM_LOAD:
// Select all Native elements (native, pill, fieldset, templateGroup) which are NOT nested = Root level.
$feSpecNative = $this->db->getNativeFormElements(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER, ['no', $this->formSpec["id"], 'native,container', 0], $this->formSpec);
$feSpecNative = $this->dbArray[$this->dbIndexQfq]->getNativeFormElements(SQL_FORM_ELEMENT_SPECIFIC_CONTAINER, ['no', $this->formSpec["id"], 'native,container', 0], $this->formSpec);
break;
case FORM_SAVE:
......@@ -697,7 +705,7 @@ class QuickFormQuery {
*/
public function getNativeFormElements($sql, array $param, $formSpec) {
$feSpecNative = $this->db->sql($sql, ROW_REGULAR, $param);
$feSpecNative = $this->dbArray[$this->dbIndexQfq]->sql($sql, ROW_REGULAR, $param);
$feSpecNative = HelperFormElement::formElementSetDefault($feSpecNative);
......@@ -1057,7 +1065,7 @@ class QuickFormQuery {
*/
private function fillStoreWithRecord($table, $recordId, $store = STORE_RECORD) {
if ($recordId !== false && $recordId > 0) {
$record = $this->db->sql("SELECT * FROM $table WHERE id = ?", ROW_EXPECT_1, [$recordId]);
$record = $this->dbArray[$this->dbIndexData]->sql("SELECT * FROM $table WHERE id = ?", ROW_EXPECT_1, [$recordId]);
$this->store->setStore($record, $store, true);
}
}
......
......@@ -60,26 +60,20 @@ class Database {
* Returns current data base handle from Store[System][SYSTEM_DBH].
* If not exists: open database and store the new dbh in Store[System][SYSTEM_DBH]
*
* @param int $dbIndex Typically '1' for Data, optional 2 for external Form/FormElement
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
public function __construct($mode = MODE_DB_REGULAR) {
public function __construct($dbIndex = 1) {
$dbInit = '';
switch ($mode) {
case MODE_DB_REGULAR:
$this->store = Store::getInstance();
$config = $this->store->getStore(STORE_SYSTEM);
$this->sqlLog = $this->store->getVar(SYSTEM_SQL_LOG, STORE_SYSTEM);
$dbInit = $this->store->getVar(SYSTEM_DB_INIT, STORE_SYSTEM);
break;
case MODE_DB_NO_LOG:
$configClass = new Config();
$config = $configClass->readConfig();
break;
default:
throw new \qfq\CodeException('Unknown mode: ' . $mode, ERROR_UNKNOWN_MODE);
}
$this->store = Store::getInstance();
$this->sqlLog = $this->store->getVar(SYSTEM_SQL_LOG, STORE_SYSTEM);
$dbInit = $this->store->getVar(SYSTEM_DB_INIT, STORE_SYSTEM);
$config = $this->getConnectionDetails($dbIndex);
if ($this->mysqli === null) {
$this->mysqli = $this->dbConnect($config);
......@@ -91,6 +85,31 @@ class Database {
}
}
/**
* Depending on $dbIndex, read DB_?_SERVER ... crendentials.
* If $dbIndex==1 but no DB_1_xxx specified, take the default DB_xxxx - old config.qfq.ini style
*
* @param $dbIndex 1,2,...
*
* @return array
* @throws CodeException
* @throws UserFormException
*/
private function getConnectionDetails($dbIndex) {
$config = $this->store->getStore(STORE_SYSTEM);
if (isset($config["DB_" . $dbIndex . "_SERVER"])) {
$config[SYSTEM_DB_SERVER] = $config["DB_" . $dbIndex . "_SERVER"];
$config[SYSTEM_DB_USER] = $config["DB_" . $dbIndex . "_USER"];
$config[SYSTEM_DB_PASSWORD] = $config["DB_" . $dbIndex . "_PASSWORD"];
$config[SYSTEM_DB_NAME] = $config["DB_" . $dbIndex . "_NAME"];
} elseif ($dbIndex != 1) {
throw new UserFormException("DB Handle not found in config: $dbIndex", ERROR_INVALID_VALUE);
}
return $config;
}
/**
* Open mysqli database connection if not already done.
......
......@@ -136,6 +136,9 @@ class Config {
*/
private static function setDefaults(array $config) {
// Defaults
Support::setIfNotSet($config, SYSTEM_DB_INDEX_DATA, '1');
Support::setIfNotSet($config, SYSTEM_DB_INDEX_QFQ, '1');
Support::setIfNotSet($config, SYSTEM_DATE_FORMAT, 'yyyy-mm-dd');
Support::setIfNotSet($config, SYSTEM_SHOW_DEBUG_INFO, SYSTEM_SHOW_DEBUG_INFO_AUTO);
Support::setIfNotSet($config, SYSTEM_SQL_LOG, SYSTEM_SQL_LOG_FILE);
......@@ -178,7 +181,6 @@ class Config {
Support::setIfNotSet($config, SYSTEM_GFX_EXTRA_BUTTON_INFO_BELOW, '<span class="glyphicon glyphicon-info-sign text-info" aria-hidden="true"></span>');
Support::setIfNotSet($config, SYSTEM_EXTRA_BUTTON_INFO_CLASS, '');
Support::setIfNotSet($config, SYSTEM_DB_UPDATE, SYSTEM_DB_UPDATE_AUTO);
Support::setIfNotSet($config, SYSTEM_RECORD_LOCK_TIMEOUT_SECONDS, SYSTEM_RECORD_LOCK_TIMEOUT_SECONDS_DEFAULT);
......
......@@ -102,31 +102,31 @@ class Store {
// TYPO3_FE_USER_UID => SANITIZE_ALLOW_DIGIT,
// TYPO3_FE_USER_GROUP => SANITIZE_ALLOW_ALNUMX,
CLIENT_SIP => SANITIZE_ALLOW_ALNUMX,
CLIENT_TYPO3VARS => SANITIZE_ALLOW_ALNUMX,
CLIENT_RECORD_ID => SANITIZE_ALLOW_DIGIT,
CLIENT_KEY_SEM_ID => SANITIZE_ALLOW_DIGIT,
CLIENT_SIP => SANITIZE_ALLOW_ALNUMX,
CLIENT_TYPO3VARS => SANITIZE_ALLOW_ALNUMX,
CLIENT_RECORD_ID => SANITIZE_ALLOW_DIGIT,
CLIENT_KEY_SEM_ID => SANITIZE_ALLOW_DIGIT,
CLIENT_KEY_SEM_ID_USER => SANITIZE_ALLOW_DIGIT,
CLIENT_PAGE_ID => SANITIZE_ALLOW_DIGIT,
CLIENT_PAGE_TYPE => SANITIZE_ALLOW_DIGIT,
CLIENT_PAGE_LANGUAGE => SANITIZE_ALLOW_DIGIT,
CLIENT_FORM => SANITIZE_ALLOW_ALNUMX,
CLIENT_PAGE_ID => SANITIZE_ALLOW_DIGIT,
CLIENT_PAGE_TYPE => SANITIZE_ALLOW_DIGIT,
CLIENT_PAGE_LANGUAGE => SANITIZE_ALLOW_DIGIT,
CLIENT_FORM => SANITIZE_ALLOW_ALNUMX,
// Part of $_SERVER. Missing vars must be requested individual with the needed sanitize class.
CLIENT_SCRIPT_URL => SANITIZE_ALLOW_ALNUMX,
CLIENT_SCRIPT_URI => SANITIZE_ALLOW_ALNUMX,
CLIENT_HTTP_HOST => SANITIZE_ALLOW_ALNUMX,
CLIENT_SCRIPT_URL => SANITIZE_ALLOW_ALNUMX,
CLIENT_SCRIPT_URI => SANITIZE_ALLOW_ALNUMX,
CLIENT_HTTP_HOST => SANITIZE_ALLOW_ALNUMX,
CLIENT_HTTP_USER_AGENT => SANITIZE_ALLOW_ALNUMX,
CLIENT_SERVER_NAME => SANITIZE_ALLOW_ALNUMX,
CLIENT_SERVER_NAME => SANITIZE_ALLOW_ALNUMX,
CLIENT_SERVER_ADDRESS => SANITIZE_ALLOW_ALNUMX,
CLIENT_SERVER_PORT => SANITIZE_ALLOW_DIGIT,
CLIENT_SERVER_PORT => SANITIZE_ALLOW_DIGIT,
CLIENT_REMOTE_ADDRESS => SANITIZE_ALLOW_ALNUMX,
CLIENT_REQUEST_SCHEME => SANITIZE_ALLOW_ALNUMX,
CLIENT_SCRIPT_FILENAME => SANITIZE_ALLOW_ALNUMX,
CLIENT_QUERY_STRING => SANITIZE_ALLOW_ALL,
CLIENT_REQUEST_URI => SANITIZE_ALLOW_ALL,
CLIENT_SCRIPT_NAME => SANITIZE_ALLOW_ALNUMX,
CLIENT_PHP_SELF => SANITIZE_ALLOW_ALNUMX,
CLIENT_QUERY_STRING => SANITIZE_ALLOW_ALL,
CLIENT_REQUEST_URI => SANITIZE_ALLOW_ALL,
CLIENT_SCRIPT_NAME => SANITIZE_ALLOW_ALNUMX,
CLIENT_PHP_SELF => SANITIZE_ALLOW_ALNUMX,
// CLIENT_UPLOAD_FILENAME => SANITIZE_ALLOW_ALLBUT,
// SYSTEM_DBUSER => SANITIZE_ALLOW_ALNUMX,
......@@ -285,15 +285,32 @@ class Store {
* @throws UserFormException
*/
private static function checkMandatoryParameter(array $config) {
// Check mandatory config vars.
$names = array('DB_USER', 'DB_SERVER', 'DB_PASSWORD', 'DB_NAME', 'SQL_LOG', 'SQL_LOG_MODE');
$names = array_merge(['SQL_LOG', 'SQL_LOG_MODE'],
self::dbCredentialName($config[SYSTEM_DB_INDEX_DATA]),
self::dbCredentialName($config[SYSTEM_DB_INDEX_QFQ]));
foreach ($names as $name) {
if (!isset($config[$name])) {
throw new qfq\UserFormException ("Missing configuration in `config.ini`: $name", ERROR_MISSING_CONFIG_INI_VALUE);
throw new qfq\UserFormException ("Missing configuration in `" . CONFIG_INI . "`: $name", ERROR_MISSING_CONFIG_INI_VALUE);
}
}
}
/**
*
*/
private static function dbCredentialName($index) {
$names = array();
$names[] = 'DB_' . $index . '_USER';
$names[] = 'DB_' . $index . '_SERVER';
$names[] = 'DB_' . $index . '_PASSWORD';
$names[] = 'DB_' . $index . '_NAME';
return $names;
}
/**
* Set or overwrite a complete store.
*
......
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