[TYPO3-core] RFC #16902 Bug: Fatal error in tslib_content_text (was: No FE output)
Jigal van Hemert
jigal at xs4all.nl
Sat Jan 15 22:10:18 CET 2011
Hi,
On 14-1-2011 21:35, JoH asenau wrote:
> Fatal error: Cannot unset string offsets in
> /home/typo3_src-4.5.0beta3/typo3/sysext/cms/tslib/content/class.tslib_content_text.php
> on line 46
>
> This revealed a problem with the tslib_content methods, when the $conf
> Parameter is not handed over as an Array but i.e. as a string.
This reveals a problem in PHP where strings can also be indexed like arrays.
Adding type hinting to the parameter list will still cause fatal errors,
only now in the call to the content method itself. It will reveal the
true cause of the problem, mentioning that an array is expected while a
string was sent.
IIRC this shouldn't be used because there seem to be a lot of old,
broken extensions out there which send NULL values instead of arrays.
The TYPO3 API used to accept these, but would now cause fatal errors.
The solution to allow NULL values would be:
function sampleFunction (array $parameter = NULL) {
if (is_null($parameter)) {
$parameter = array();
}
...
This produces an error if anything other than an array or a NULL value
is passed. And gracefully uses empty arrays if a NULL value is passed.
Maybe the RM can decide which way to go?
--
Kind regards / met vriendelijke groet,
Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh
More information about the TYPO3-team-core
mailing list