Issue Bug Closed

#31139better condition in versionOL of t3lib_tstemplate

Stefan Froemken 10/20/11, 13:13 updated 10/24/17, 20:19

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

Reviews 6