Project

General

Profile

Actions

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.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Communication
Target version:
-
Start date:
2008-03-12
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.2
PHP Version:
5.0
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

20080312_arrayMergeBug_pibase.diff (542 Bytes) 20080312_arrayMergeBug_pibase.diff Administrator Admin, 2008-03-12 13:22
Actions #1

Updated by Dmitry Dulepov over 16 years ago

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...

Actions #2

Updated by Patrick Lobacher over 16 years ago

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?

Actions #3

Updated by Oliver Hader over 16 years ago

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.

Actions #4

Updated by Patrick Lobacher over 16 years ago

Okay, from this point of view you are right. I have contacted the owner of the extension to fix this problem asap.

Actions #5

Updated by Ingo Renner over 16 years ago

I agree with Olly, can we close this issue?

Actions #6

Updated by Ingo Renner over 16 years ago

... I mean what sense does an API have if we do not enforce it or can rely on developers to stick to it...

Actions

Also available in: Atom PDF