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

Refs #11998 - Add qfq function cache

parent cc7e6397
Pipeline #5051 passed with stages
in 3 minutes and 49 seconds
...@@ -2004,8 +2004,6 @@ Example tt-content record for the calling report:: ...@@ -2004,8 +2004,6 @@ Example tt-content record for the calling report::
}                                                                     }                                                                    
.. _download: .. _download:
Download Download
......
...@@ -423,7 +423,12 @@ class Report { ...@@ -423,7 +423,12 @@ class Report {
} }
/** /**
* @param $cmd * Split $cmd into a) function name, b) call parameter and c) return values.
* Fire function: tt-content QFQ report
* Return 'return values' in STORE_RECORD and QFQ function output in {{_output:R}}.
* BTW: the QFQ function is cached and read only once. The evaluation is not cached.
*
* @param $cmd # 'getFirstName(pId) => firstName, myLink'
* @throws \CodeException * @throws \CodeException
* @throws \DbException * @throws \DbException
* @throws \DownloadException * @throws \DownloadException
...@@ -436,7 +441,9 @@ class Report { ...@@ -436,7 +441,9 @@ class Report {
* @throws \UserFormException * @throws \UserFormException
* @throws \UserReportException * @throws \UserReportException
*/ */
private function doFunction($cmd) { private function doQfqFunction($cmd) {
// QFQ function cache
static $functionCache = array();
// Explode cmd // Explode cmd
OnString::splitFunctionCmd($cmd, $rcFunctionName, $rcFunctionParam, $rcReturnParam); OnString::splitFunctionCmd($cmd, $rcFunctionName, $rcFunctionParam, $rcReturnParam);
...@@ -453,22 +460,27 @@ class Report { ...@@ -453,22 +460,27 @@ class Report {
$this->store->setStore($tmp, STORE_RECORD, true); $this->store->setStore($tmp, STORE_RECORD, true);
// Get tt_content record bodytext // Get tt_content record bodytext
$bodytextArr = $this->db->getBodyText($rcFunctionName); if (isset($functionCache[$rcFunctionName])) {
$bodytextArr = $functionCache[$rcFunctionName];
} else {
$bodytextArr = $this->db->getBodyText($rcFunctionName);
$btp = new BodytextParser();
$bodytextArr[T3DATA_BODYTEXT] = $btp->process($bodytextArr[T3DATA_BODYTEXT]);
$functionCache[$rcFunctionName] = $bodytextArr;
}
// Fake uid/pid for meaningful error messages // Fake uid/pid for meaningful error messages
$this->store->setVar(TYPO3_PAGE_ID, $bodytextArr[T3DATA_PID], STORE_TYPO3); $this->store->setVar(TYPO3_PAGE_ID, $bodytextArr[T3DATA_PID], STORE_TYPO3);
$this->store->setVar(TYPO3_TT_CONTENT_UID, $bodytextArr[T3DATA_UID], STORE_TYPO3); $this->store->setVar(TYPO3_TT_CONTENT_UID, $bodytextArr[T3DATA_UID], STORE_TYPO3);
$btp = new BodytextParser();
$bodytextArr[T3DATA_BODYTEXT] = $btp->process($bodytextArr[T3DATA_BODYTEXT]);
$report = new Report(array(), $this->evaluate, $this->phpUnit);
// Fire bodytext. output is purged // Fire bodytext. output is purged
$report = new Report(array(), $this->evaluate, $this->phpUnit);
$storeRecord[COLUMN_FUNCTION_OUTPUT] = $report->process($bodytextArr[T3DATA_BODYTEXT]); $storeRecord[COLUMN_FUNCTION_OUTPUT] = $report->process($bodytextArr[T3DATA_BODYTEXT]);
unset($report); unset($report);
// Restore and fill STORE_RECORD // Copy defined 'return values' to STORE_RECORD
$tmp = $this->store->getStore(STORE_RECORD); $tmp = $this->store->getStore(STORE_RECORD);
foreach ($rcReturnParam as $key) { foreach ($rcReturnParam as $key) {
$storeRecord[$key] = $tmp[$key] ?? ''; $storeRecord[$key] = $tmp[$key] ?? '';
...@@ -478,7 +490,6 @@ class Report { ...@@ -478,7 +490,6 @@ class Report {
// Restore old state // Restore old state
$this->store->setStore($storeRecord, STORE_RECORD, true); $this->store->setStore($storeRecord, STORE_RECORD, true);
$this->store->setStore($storeTypo3, STORE_TYPO3, true); $this->store->setStore($storeTypo3, STORE_TYPO3, true);
} }
/** /**
...@@ -561,7 +572,7 @@ class Report { ...@@ -561,7 +572,7 @@ class Report {
// If defined, fire QFQ function // If defined, fire QFQ function
if ($this->frArray[$fullLevel . "." . TOKEN_FUNCTION] != '') { if ($this->frArray[$fullLevel . "." . TOKEN_FUNCTION] != '') {
$this->doFunction($this->frArray[$fullLevel . "." . TOKEN_FUNCTION]); $this->doQfqFunction($this->frArray[$fullLevel . "." . TOKEN_FUNCTION]);
} }
$sql = $this->variables->doVariables($this->frArray[$fullLevel . "." . TOKEN_SQL]); $sql = $this->variables->doVariables($this->frArray[$fullLevel . "." . TOKEN_SQL]);
......
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