Issue Bug Closed

#37609t3lib_div::callUserFunction causes PHP warnings

Anonymous 05/30/12, 14:53 updated 10/19/17, 21:37

Description

line 4595 of t3lib/class.t3lib_div.php from the current trunk causes php warnings due to lack of conditions:

4591         public static function callUserFunction($funcName, &$params, &$ref, $checkPrefix = 'user_', $errorMode = 0) {
4592                 $content = FALSE;
4593
4594                         // Check persistent object and if found, call directly and exit.
4595                 if (is_array($GLOBALS['T3_VAR']['callUserFunction'][$funcName])) {
4596                         return call_user_func_array(
4597                                 array(&$GLOBALS['T3_VAR']['callUserFunction'][$funcName]['obj'],
4598                                         $GLOBALS['T3_VAR']['callUserFunction'][$funcName]['method']),
4599                                 array(&$params, &$ref)
4600                         );
4601                 }

in case $funcName is an existing key of the array $GLOBALS[‘T3_VAR’][‘callUserFunction’] everything works fine.
in case it isn’t, it produces warnings like this:

Core: Error handler (FE): PHP Warning: Illegal offset type in /opt/typo3/typo3_src-4.5/t3lib/class.t3lib_div.php line 4595

so i guess adding two extra conditions to the if statement like this

4595                 if (array_key_exists('callUserFunction', $GLOBALS['T3_VAR']) && array_key_exists($funcName, $GLOBALS['T3_VAR']['callUserFunction']) && is_array($GLOBALS['T3_VAR']['callUserFunction'][$funcName])) {

fixes that, right?

Reviews 1