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

Michael Stucki michael at typo3.org
Sat Feb 2 13:30:22 CET 2008


Hi Martin,

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

OK, agreed. So the only possible error I can imagine is that someone who is
lazy might call the function with an array as input. This could be solved
however by using type hinting in the function header.

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

No, it was the only occurence I found which checks it this way. Most checks
are done using isset($arr['keyname']) and some are even not doing any
checks at all.

So I agree, the empty array is fine, and the tslib_content check above can
be removed.

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

Why shouldn't it work? As I said, it's just the phpdoc note which is wrong.

Anyway, just search for it in typo3_src and you find that it's used to
detect the XML encoding in t3lib_tceforms and t3lib_flexformtools.

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

If you like... :-)

- michael
-- 
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/


More information about the TYPO3-team-core mailing list