Bug #18306
closed
TYPO3 crashes because of array_merge error with PHP5 (pibase)
Added by Patrick Lobacher over 16 years ago.
Updated over 16 years ago.
Description
In PHP 5 the function array_merge needs both arguments to be arrays.
Sometimes this is not the case so the arguments should be casted anyway to avoid this error:
Line 502: /typo3/sysext/cms/tslib/class.tslib_pibase.php
$wrapper = array_merge($wrapper,$wrapArr);
should be changed to
$wrapper = array_merge($wrapper,(array)$wrapArr);
The line above is in the function pi_list_browseresults
(issue imported from #M7840)
Files
Well, it is easy to make a type cast but I truly would like to know why it is not an array in some cases...
Yes you are right. In this case it was a request on the german mailing list to solve a specific error.
The user uses the extension "feusersview" and there is a call in file "pi1/class.tx_feusersview_pi1.php" in line 249:
$subpartArray["###BROWSE###"] = $this->pi_list_browseresults(1, "", $wrapArr);
But $wrapArr ist never filled in this file so it is empty and causes the array_merge() error.
Sure it would help to contact owner of the extension, but I knew a few other Extensions where this specific problem with array_merge occurs as no one has ever thought about.
As it doesn't hurt I suggest to cast the last parameter - what do you think?
The intention of using type hints in the TYPO3 Core was to force extension developers to use the correct expected types. Next steps in TYPO3 4.3 could be to add these type hints also to other classes (e.g. also to tslib_pibase::pi_list_browseresults) and then extension developers have to take care. Thus, it's just a question of time.
With using the array type hint e.g. all "is_array($expectedAsArray)" can be removed from foreach loops.
My opinion: Extensions have to be changed.
Okay, from this point of view you are right. I have contacted the owner of the extension to fix this problem asap.
I agree with Olly, can we close this issue?
... I mean what sense does an API have if we do not enforce it or can rely on developers to stick to it...
Also available in: Atom
PDF