Bug #31139
closedbetter condition in versionOL of t3lib_tstemplate
100%
Description
Hello Core-Team,
in current TYPO3 4.5.7 you have following method in class.t3lib_tstemplate.php:
function versionOL(&$row) { if (is_object($GLOBALS['TSFE'])) { // Frontend: $GLOBALS['TSFE']->sys_page->versionOL('sys_template', $row); } else { // Backend: t3lib_BEfunc::workspaceOL('sys_template', $row); } }
You only need to set something:
$GLOBALS['TSFE']->register['hello'] = 1;
or play with cObj in BE Mode and $GLOBALS['TSFE'] get's a value.
In this case is_object($GLOBALS['TSFE']) returns true, because it is of class stdClass now.
So...to prevent calling $GLOBALS['TSFE']->sys_page->versionOL in BE-Mode it's better to modify the condition that way:
function versionOL(&$row) { if (isset($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE']) && get_class($GLOBALS['TSFE']) == 'tslib_fe') { // Frontend: $GLOBALS['TSFE']->sys_page->versionOL('sys_template', $row); } else { // Backend: t3lib_BEfunc::workspaceOL('sys_template', $row); } }
Stefan
Updated by Benni Mack almost 13 years ago
Hey,
how about
if ($GLOBALS['TSFE'] && $GLOBALS['TSFE']->sys_page) {
...
}
?
Updated by Stefan Froemken almost 13 years ago
Your version works, too. But I don't know if this is the more better/best version.
Updated by Steffen Ritter almost 13 years ago
- Status changed from New to Accepted
- Complexity set to easy
Stefan Froemken wrote:
Your version works, too. But I don't know if this is the more better/best version.
As Benni's shorter and has one check less, it is better. Furthermore you may have tslib_fe class with sys_page ==null.
Would you mind to push a change to Gerrit?
Updated by Markus Klein almost 13 years ago
I disagree.
Benni's version will cause a warning when sys_page does not exist.
Please stick to thorough checking with isset().
Updated by Gerrit Code Review almost 13 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/7043
Updated by Mario Rimann almost 13 years ago
I checked and the condition is built way different in 4.6 and 4.7 -> so I pushed the patch only for 4.5
Updated by Gerrit Code Review almost 13 years ago
Patch set 2 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/7043
Updated by Gerrit Code Review almost 13 years ago
Patch set 3 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/7043
Updated by Gerrit Code Review almost 13 years ago
Patch set 4 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/7043
Updated by Ernesto Baschny over 12 years ago
- Target version changed from 4.5.8 to 4.5.12
Updated by Gerrit Code Review over 12 years ago
Patch set 5 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/7043
Updated by Mario Rimann over 12 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset a49c4a490fa63e781456f5f0125a434550d737dc.
Updated by Stefano Cecere over 12 years ago
i found that this change i causing fatal errors.
(i checked (and another user found it , too) with yag extension
see http://forge.typo3.org/issues/36487 for full error report
the problem is
function versionOL(&$row) { if (TYPO3_MODE === 'FE') { // Frontend: $GLOBALS['TSFE']->sys_page->versionOL('sys_template', $row); } else { // Backend: t3lib_BEfunc::workspaceOL('sys_template', $row); } }
which i have to revert to:
function versionOL(&$row) { if (is_object($GLOBALS['TSFE'])) { // Frontend: $GLOBALS['TSFE']->sys_page->versionOL('sys_template', $row); } else { // Backend: t3lib_BEfunc::workspaceOL('sys_template', $row); } }
(i tried to XCLASS versionOL with the working one, but it seems not possible.. old versionOL() is always called :(
what do you think?
Updated by Stefano Cecere over 12 years ago
sorry.. i think the problem is somewhere else..
versionOL gets called from t3lib_TStemplate->runThroughTemplates( ) but the sys_page is not fully instantiated...
the problem seems to be in pt_extbase
sorry for this false alarm
Updated by Andy Grunwald over 12 years ago
Hey all,
the comitted changed cause a Fatal error in the frontend if you use an eID and you work with the tstemplate class.
Why? It is quite easy. eID has the TYPO3_MODE FE but has no full blown up Frontend (e.g. $GLOBALS['TSFE'] / $GLOBALS['TSFE']->sys_page).
In our case we create via direct_mail api new mailings via an eid.
Direct mail calls this method to get the correct charset for this page.
So, with the new patch we got
Fatal error: Call to a member function versionOL() on a non-object in /var/www/dasgastroportal.dus.wmdb.de/typo3_src-4.5.15/t3lib/class.t3lib_tstemplate.php on line 753
In my opinion, this is a regression.
I will provide a patch.
See Bug #36981 "Regression of "better condition in versionOL of t3lib_tstemplate" (#31139)" for more information.
Updated by Riccardo De Contardi almost 7 years ago
- Status changed from Resolved to Closed