Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
da4212db
Commit
da4212db
authored
Mar 20, 2021
by
Carsten Rose
Browse files
Refs #11998 - Add qfq function cache
parent
cc7e6397
Pipeline
#5051
passed with stages
in 3 minutes and 49 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Documentation/Report.rst
View file @
da4212db
...
...
@@ -2004,8 +2004,6 @@ Example tt-content record for the calling report::
}
.. _download:
Download
...
...
extension/Classes/Core/Report/Report.php
View file @
da4212db
...
...
@@ -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 \DbException
* @throws \DownloadException
...
...
@@ -436,7 +441,9 @@ class Report {
* @throws \UserFormException
* @throws \UserReportException
*/
private
function
doFunction
(
$cmd
)
{
private
function
doQfqFunction
(
$cmd
)
{
// QFQ function cache
static
$functionCache
=
array
();
// Explode cmd
OnString
::
splitFunctionCmd
(
$cmd
,
$rcFunctionName
,
$rcFunctionParam
,
$rcReturnParam
);
...
...
@@ -453,22 +460,27 @@ class Report {
$this
->
store
->
setStore
(
$tmp
,
STORE_RECORD
,
true
);
// 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
$this
->
store
->
setVar
(
TYPO3_PAGE_ID
,
$bodytextArr
[
T3DATA_PID
],
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
$report
=
new
Report
(
array
(),
$this
->
evaluate
,
$this
->
phpUnit
);
$storeRecord
[
COLUMN_FUNCTION_OUTPUT
]
=
$report
->
process
(
$bodytextArr
[
T3DATA_BODYTEXT
]);
unset
(
$report
);
//
Restore and fill
STORE_RECORD
//
Copy defined 'return values' to
STORE_RECORD
$tmp
=
$this
->
store
->
getStore
(
STORE_RECORD
);
foreach
(
$rcReturnParam
as
$key
)
{
$storeRecord
[
$key
]
=
$tmp
[
$key
]
??
''
;
...
...
@@ -478,7 +490,6 @@ class Report {
// Restore old state
$this
->
store
->
setStore
(
$storeRecord
,
STORE_RECORD
,
true
);
$this
->
store
->
setStore
(
$storeTypo3
,
STORE_TYPO3
,
true
);
}
/**
...
...
@@ -561,7 +572,7 @@ class Report {
// If defined, fire QFQ function
if
(
$this
->
frArray
[
$fullLevel
.
"."
.
TOKEN_FUNCTION
]
!=
''
)
{
$this
->
doFunction
(
$this
->
frArray
[
$fullLevel
.
"."
.
TOKEN_FUNCTION
]);
$this
->
do
Qfq
Function
(
$this
->
frArray
[
$fullLevel
.
"."
.
TOKEN_FUNCTION
]);
}
$sql
=
$this
->
variables
->
doVariables
(
$this
->
frArray
[
$fullLevel
.
"."
.
TOKEN_SQL
]);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment