Bug #31079
closedNon-array argument passed to t3lib_div::implodeAttributes()
100%
Description
In an install, TYPO3 crashes when I switch from default language (French) to German (L=1):
#1: PHP Catchable Fatal Error: Argument 1 passed to t3lib_div::implodeAttributes() must be an array, boolean given, called in /path/to/typo3/sysext/cms/tslib/class.tslib_menu.php on line 1503 and defined in /path/to/t3lib/class.t3lib_div.php line 2000
trace:
t3lib_error_Exception thrown in file /path/to/t3lib/error/class.t3lib_error_errorhandler.php in line 105. 20 t3lib_error_ErrorHandler::handleError(4096, "Argument 1 passed to t3lib_div::implodeAttributes(…slib/class.tslib_menu.php on line 1503 and defined", "/path/to/t3lib/class.t3lib_div.php", 2000, array) /path/to/t3lib/class.t3lib_div.php: 01998: * @return string Imploded attributes, eg. 'bgcolor="red" border="0"' 01999: */ 02000: public static function implodeAttributes(array $arr, $xhtmlSafe = FALSE, $dontOmitBlankAttribs = FALSE) { 02001: if ($xhtmlSafe) { 02002: $newArr = array(); 19 t3lib_div::implodeAttributes(boolean, 1) /path/to/typo3/sysext/cms/tslib/class.tslib_menu.php: 01501: */ 01502: function setATagParts() { 01503: $this->I['A1'] = 'I['linkHREF'],1).' '.$this->I['val']['ATagParams'].$this->I['accessKey']['code'].'>'; 01504: $this->I['A2'] = ''; 01505: } 18 tslib_menu::setATagParts() /path/to/typo3/sysext/cms/tslib/class.tslib_menu.php: 01749: if (!$this->I['val']['doNotLinkIt']) {$this->I['val']['doNotLinkIt']=0;} 01750: if (!$this->I['spacer'] && $this->I['val']['doNotLinkIt']!=1) { 01751: $this->setATagParts(); 01752: } else { 01753: $this->I['A1'] = ''; 17 tslib_tmenu::writeMenu() /path/to/typo3/sysext/cms/tslib/class.tslib_menu.php: 01317: // Reset the menu item count for the submenu 01318: $GLOBALS['TSFE']->register['count_MENUOBJ'] = 0; 01319: $content = $submenu->writeMenu(); 01320: // Restore the item count now that the submenu has been handled 01321: $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempCountMenuObj; 16 tslib_menu::subMenu("3", NULL) /path/to/typo3/sysext/cms/tslib/class.tslib_menu.php: 01933: // Add part to the accumulated result + fetch submenus 01934: if (!$this->I['spacer']) { 01935: $this->I['theItem'].= $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']); 01936: } 01937: $part = isset($this->I['val']['wrapItemAndSub.']) 15 tslib_tmenu::extProc_afterLinking(0) /path/to/typo3/sysext/cms/tslib/class.tslib_menu.php: 01815: 01816: // Calling extra processing function 01817: $this->extProc_afterLinking($key); 01818: } 01819: return $this->extProc_finish(); 14 tslib_tmenu::writeMenu() /path/to/typo3/sysext/cms/tslib/content/class.tslib_content_hierarchicalmenu.php: 00070: $menu->makeMenu(); 00071: 00072: $theValue .= $menu->writeMenu(); 00073: 00074: } 13 tslib_content_HierarchicalMenu::render(array) /path/to/typo3/sysext/cms/tslib/class.tslib_content.php: 00599: $contentObject = $this->getContentObject($name); 00600: if ($contentObject) { 00601: $content .= $contentObject->render($conf); 00602: } else { 00603: // call hook functions for extra processing 12 tslib_cObj::cObjGetSingle("HMENU", array, "TemplaVoila_ProcObjPath--lib*menu*main.") /path/to/typo3conf/ext/templavoila/pi1/class.tx_templavoila_pi1.php: 00635: if (trim($LP[$key]['TypoScriptObjPath'])) { 00636: list($name, $conf) = $tsparserObj->getVal(trim($LP[$key]['TypoScriptObjPath']),$GLOBALS['TSFE']->tmpl->setup); 00637: $dataValues[$key][$valueKey] = $cObj->cObjGetSingle($name,$conf,'TemplaVoila_ProcObjPath--'.str_replace('.','*',$LP[$key]['TypoScriptObjPath']).'.'); 00638: } 00639: } 11 tx_templavoila_pi1::processDataValues(array, array, NULL, "vDEF", boolean) /path/to/typo3conf/ext/templavoila/pi1/class.tx_templavoila_pi1.php: 00357: // Store the original data values before the get processed. 00358: $originalDataValues = $dataValues; 00359: $this->processDataValues($dataValues,$dataStruct['ROOT']['el'],$TOlocalProc,$vKey, ($this->conf['renderUnmapped'] !== 'false' ? TRUE : $TO['MappingInfo']['ROOT']['el'])); 00360: 00361: // Hook: renderElement_postProcessDataValues
Updated by Xavier Perseguers about 13 years ago
The argument that is passed in this very scenario is "de/". If I remove the parameter constraint from being an array, then "it works".
Updated by Steffen Ritter about 13 years ago
Xavier Perseguers wrote:
The argument that is passed in this very scenario is "de/". If I remove the parameter constraint from being an array, then "it works".
but this solution does not feel right, at least not just "removing" it...
if so we should add $param = is_array($param) ? $param : array($param);
This would be the clean way, as PHP functions "implode" non arrays with just returning them.
Updated by Xavier Perseguers about 13 years ago
Ideally I'd like to understand what causes this bug on this install and not on another one with similar language menus. But all in all, I fear it won't be possible to fix that from the caller perspective as we had phpDoc only for a very long time and we have all sorts of use out there.
So your suggestion would be to have this?
public static function t3lib_div::implodeAttributes($param1, ...) { $param1 = is_array($param1) ? $param1 : array($param1);
I can test it.
Updated by Christian Kuhn about 13 years ago
When and why was the type hint added to the method?
Updated by Xavier Perseguers about 13 years ago
Actually I did not check, I suppose it was not there... For sure it broke the aforementioned website after upgrading from 4.5.
Updated by Xavier Perseguers about 13 years ago
This is in method signature since a very long time. Some other part in the stack trace must have been changed then.
Updated by Xavier Perseguers about 13 years ago
OK, found the bug! Patch coming soon.
Updated by Xavier Perseguers about 13 years ago
- Category set to Frontend
- Assignee set to Xavier Perseguers
Updated by Mr. Hudson about 13 years ago
- Status changed from New to Under Review
Patch set 1 of change I7a593dd7eec2bee9e9f84415ccdd592f4d767caf has been pushed to the review server.
It is available at http://review.typo3.org/6155
Updated by Xavier Perseguers about 13 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed