[TYPO3-core] RFC: #7350:PHP5ize class.t3lib_div.php

Martin Kutschker martin.kutschker-n0spam at no5pam-blackbox.net
Sat Feb 2 12:59:51 CET 2008


Michael Stucki schrieb:
> Hi Dmitry,
> 
>> Stanislas Rolland wrote:
>>> tslib_content fails:
>>>
>>> Catchable fatal error: Argument 1 passed to
>>> t3lib_div::implodeAttributes() must be an array, null given, called in
>>> /typo3/sysext/cms/tslib/class.tslib_content.php on line 4471
>> t3lib_div::get_tag_attributes did not work according to documentation. Fix
>> is attached. It may be sensitive, so I post here instead of
>> autocommitting.
>>
>> Anyway, I feel bad about mixng return value and no return value inside one
>> function, which is declared as always returning value.
> 
> How about returning false instead of an empty array?

But no attributes at all are no failure. An empty array is exactly what 
the function should return.

> Someone who is using it
> now could have checked the output using is_array(), which would match now.

Well, in tslib_context it's like this;

if (!is_array($returnedAttributes)) {
   $returnedAttributes = array();
}

I guess other could would work similar.

> Additional comments.
> 
> Have a look at t3lib_div::xmlGetHeaderAttribs() - it says that it returns
> string values, but the output is coming directly from get_tag_attributes().
> Don't know if the phpdoc comment is wrong, at least I don't see how
> get_tag_attributes() could ever return a string output. But we need to
> check it thoroughly.

Ouch, the function has issues (ie it cannot work at all). It simply 
looks for the XML prologue and feeds it into get_tag_attributes. may the 
code that was initially written deals with the real return value.

But as it is, it's broken completely. Mybe we can check, when it went 
into the Core and who is actually using it.

Masi

> If you find time for it, could you also modify change all copies of this
> function into wrappers for the t3lib_div function, and mark them as
> deprecated? Thanks!

You is who? Me? Dmitry?

Masi


More information about the TYPO3-team-core mailing list