Commit 7de0cae8 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixes #3992 (Feature): dbNameQfq & dbNameData already implemented. dbNameT3...

Fixes #3992 (Feature): dbNameQfq & dbNameData already implemented. dbNameT3 renamed from T3_DB_NAME. No more configuration in config.qfq.php necessary. Manual updated.
AbstractException.php: fixes access to uninitialized array elements.
Download.php: get dbT3 now from STORE_SYSTEM
Config.php: read 'dbNameT3' from TYPO3_CONF_VARS or from T3 config file.
QuickFormQuery.php: refactor gathering 'dbNames' - now from config.qfq.php. Fixes bug in getForwardMode() for QFQ inline editing.
parent e6d462f5
Pipeline #1106 passed with stage
in 1 minute and 59 seconds
......@@ -309,10 +309,6 @@ config.qfq.php
| LDAP_1_RDN | LDAP_1_RDN='ou=Admin,ou=example,dc=com' | Credentials for non-anonymous LDAP access. At the moment only one set of |
| LDAP_1_PASSWORD | LDAP_1_PASSWORD=mySecurePassword | |
+-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| T3_DB_NAME | T3_DB_NAME=specialt3dbname | Only necessary for inline report editing if the t3 database is not |
| | | anologous to the Data db name (but ending in _t3) - see `inline-report`_. |
+-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
Example: *typo3conf/config.qfq.php*: ::
......@@ -526,6 +522,17 @@ Extension Manager: QFQ Configuration
| cssClassColumnId | text-muted | A column in a subrecord with the name id|ID|Id gets this class. |
+-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
Automatically filled by QFQ:
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| Keyword | Description |
+===============================+====================================================================================================================================+
| dbNameData | Use this to get name of the configured 'data'-database. '{{dbNameData:Y}} |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| dbNameQfq | Use this to get name of the configured 'QFQ'-database. '{{dbNameQfq:Y}} |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| dbNameT3 | Use this to get name of the configured 'T3'-database. '{{dbNameT3:Y}} |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
.. _`CustomVariables`:
......@@ -1515,7 +1522,7 @@ Only variables that are known in a specified store can be substituted.
+-----+----------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+
| V | :ref:`STORE_VARS`: Generic variables. | See `STORE_VARS`_. |
+-----+----------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+
| Y | :ref:`STORE_SYSTEM`: a) Database, b) helper vars for logging/debugging: | See `STORE_SYSTEM`_. |
| Y | :ref:`STORE_SYSTEM`: a) Database, b) helper vars for logging/debugging: | See `STORE_SYSTEM`_. |
| | SYSTEM_SQL_RAW ... SYSTEM_FORM_ELEMENT_COLUMN, c) Any custom fields: CONTACT, HELP, ...| |
+-----+----------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+
| 0 | *Zero* - always value: 0, might be helpful if a variable is empty or undefined and | Any key |
......@@ -5035,17 +5042,8 @@ For this reason, QFQ offers an inline report editing feature whenever there is a
link symbol will appear on the right-hand side of each report record. Please note that the TYPO3 Frontend cache
is also deleted upon each inline report save.
In order for the inline report editing to work, QFQ needs to be able to access the T3 database. By default this database
is assumed to be accessible with the same credentials as specified with indexData and is assumed to be named similarly to
the indexData db name, but ending in _t3 instead of _db (e.g., mydb_db and mydb_t3).
For a standard installation and db setup, this should be the case.
You can however specify a custom T3 db name in config-qfq-php_:
::
T3_DB_NAME = customT3DbName
In order for the inline report editing to work, QFQ needs to be able to access the T3 database. This database
is assumed to be accessible with the same credentials as specified with indexQfq.
Structure
---------
......
......@@ -421,8 +421,6 @@ const SYSTEM_DB_1_SERVER = 'DB_1_SERVER';
const SYSTEM_DB_1_PASSWORD = 'DB_1_PASSWORD';
const SYSTEM_DB_1_NAME = 'DB_1_NAME';
const SYSTEM_T3_DB_NAME = 'T3_DB_NAME';
const SYSTEM_DB_INIT = 'init';
const SYSTEM_DB_INDEX_DATA = "indexData";
......@@ -431,9 +429,11 @@ const SYSTEM_DB_INDEX_QFQ = "indexQfq";
//const SYSTEM_DB_INDEX_DATA_DEPRECATED = "DB_INDEX_DATA";
//const SYSTEM_DB_INDEX_QFQ_DEPRECATED = "DB_INDEX_QFQ";
// Computed dynamically
const SYSTEM_DB_NAME_DATA = '_dbNameData';
const SYSTEM_DB_NAME_QFQ = '_dbNameQfq';
// Automatically filled by QFQ
const SYSTEM_DB_NAME_DATA = 'dbNameData';
const SYSTEM_DB_NAME_QFQ = 'dbNameQfq';
const SYSTEM_DB_NAME_T3 = 'dbNameT3';
const SYSTEM_LOG_DIR = 'logDir'; // Logging to file
const SYSTEM_LOG_DIR_DEFAULT = 'fileadmin/protected/log'; // Logging to file
......
......@@ -178,16 +178,9 @@ class QuickFormQuery {
$this->dbArray[$this->dbIndexData] = new Database($this->dbIndexData);
$dbName = $this->dbArray[$this->dbIndexData]->getDbName();
$this->store->setVar(SYSTEM_DB_NAME_DATA, $dbName, STORE_SYSTEM);
if ($this->dbIndexData != $this->dbIndexQfq) {
$this->dbArray[$this->dbIndexQfq] = new Database($this->dbIndexQfq);
$dbName = $this->dbArray[$this->dbIndexQfq]->getDbName();
}
$this->store->setVar(SYSTEM_DB_NAME_QFQ, $dbName, STORE_SYSTEM);
$this->eval = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
......@@ -213,6 +206,11 @@ class QuickFormQuery {
*/
public function getForwardMode() {
if (!isset($this->formSpec[F_FORWARD_PAGE])) {
// For QFQ inline editing: no redirect.
return [API_REDIRECT => API_ANSWER_REDIRECT_NO, API_REDIRECT_URL => ''];
}
$forwardPage = $this->formSpec[F_FORWARD_PAGE];
if ($this->formSpec[F_FORWARD_MODE] == F_FORWARD_MODE_URL_SIP) {
......@@ -1457,7 +1455,7 @@ class QuickFormQuery {
}
$bodytext = Support::htmlEntityEncodeDecode(MODE_DECODE, $_POST[REPORT_INLINE_BODYTEXT]);
$dbT3 = $this->store->getDbT3Name();
$dbT3 = $this->store->getVar(SYSTEM_DB_NAME_T3, STORE_SYSTEM);
// Update bodytext
$sql = "UPDATE $dbT3.tt_content SET bodytext = ?, tstamp = UNIX_TIMESTAMP(NOW()) WHERE uid = ?";
......
......@@ -109,9 +109,9 @@ class AbstractException extends \Exception {
$arrDebugShow = array_merge([EXCEPTION_REPORT_FULL_LEVEL => Store::getVar(SYSTEM_REPORT_FULL_LEVEL, STORE_SYSTEM)], $this->messageArrayDebug);
$arrDebugShow[EXCEPTION_SIP] = $store->getStore(STORE_SIP);
$arrDebugShow[EXCEPTION_PAGE_ID] = $t3Vars[TYPO3_PAGE_ID];
$arrDebugShow[EXCEPTION_TT_CONTENT_UID] = $t3Vars[TYPO3_TT_CONTENT_UID];
$arrDebugShow[EXCEPTION_FE_USER] = $t3Vars[TYPO3_FE_USER]??'';
$arrDebugShow[EXCEPTION_PAGE_ID] = $t3Vars[TYPO3_PAGE_ID] ?? '-';
$arrDebugShow[EXCEPTION_TT_CONTENT_UID] = $t3Vars[TYPO3_TT_CONTENT_UID] ?? '-';
$arrDebugShow[EXCEPTION_FE_USER] = $t3Vars[TYPO3_FE_USER] ?? '-';
$arrDebugShow[EXCEPTION_FE_USER_STORE_USER] = Store::getVar(TYPO3_FE_USER, STORE_USER);
// Optional existing arrays will be flattened
......
......@@ -313,7 +313,7 @@ class Download {
$this->store->setVar($key, $paramValue, STORE_SIP);
}
$dbT3 = $this->store->getDbT3Name();
$dbT3 = $this->store->getVar(SYSTEM_DB_NAME_T3,STORE_SYSTEM);
$sql = "SELECT bodytext FROM $dbT3.tt_content WHERE uid = ?";
$tt_content = $this->db->sql($sql, ROW_EXPECT_1, [$uid]);
......
......@@ -93,11 +93,14 @@ class Config {
$pathTypo3Conf = __DIR__ . '/../../..';
}
// In case there is a $configIni given: do not try to include T3 LocalConfiguration.php
// In case of missing $configIni
if (empty($configIni)) {
# Read 'LocalConfiguration.php'
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][EXT_KEY])) {
$configT3qfq = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][EXT_KEY]);
$configT3qfq[SYSTEM_DB_NAME_T3] = $GLOBALS['TYPO3_CONF_VARS']['DB']['database'];
} else {
$all = include($pathTypo3Conf . '/' . CONFIG_T3);
if (empty($all) || $all === true) {
......@@ -108,6 +111,8 @@ class Config {
if (!is_array($configT3qfq)) {
throw new qfq\UserFormException ("Error read file: " . $pathTypo3Conf . '/' . CONFIG_T3, ERROR_IO_READ_FILE);
}
$configT3qfq[SYSTEM_DB_NAME_T3] = $all['DB']['database'];
unset($all);
}
$configIni = $pathTypo3Conf . '/' . CONFIG_QFQ_INI;
......
......@@ -455,12 +455,27 @@ class Store {
$config = self::doSystemPath($config);
$config = self::adjustConfig($config);
$config = self::setAutoConfigValue($config);
self::checkMandatoryParameter($config);
self::setStore($config, STORE_SYSTEM, true);
}
/**
* Set automatic filled values
*
* @param array $config
* @return array
*/
public static function setAutoConfigValue(array $config) {
$config[SYSTEM_DB_NAME_DATA] = $config['SYSTEM_DB_' . $config[SYSTEM_DB_INDEX_DATA] . '_NAME'] ?? '';
$config[SYSTEM_DB_NAME_QFQ] = $config['SYSTEM_DB_' . $config[SYSTEM_DB_INDEX_QFQ] . '_NAME'] ?? '';
return $config;
}
/**
* Copy the BodyText as well as some T3 specific vars to STORE_TYPO3.
* Attention: if called through API, there is no T3 environment. The only values which are available are fe_user
......@@ -959,31 +974,4 @@ class Store {
$store = Store::getInstance();
$store->setStore(array_merge($store->getStore($storeName), $append), $storeName, true);
}
/**
* Gets the db T3 name:
* - if defined by T3_DB_NAME in config
* - else: construct databasename_t3 from databasename_db
*
* @return string
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public static function getDbT3Name() {
$dbT3Name = self::getVar(SYSTEM_T3_DB_NAME, STORE_SYSTEM . STORE_EMPTY, SANITIZE_ALLOW_ALNUMX);
if (!$dbT3Name) {
$dbIndexData = self::getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
$dbData = new Database($dbIndexData);
$dbDataName = $dbData->getDbName();
$dbT3Name = substr($dbDataName, 0, strrpos($dbDataName, "_") + 1) . 't3';
}
return $dbT3Name;
}
}
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