[TYPO3-core] RFC #10231: Bug: split() is deprecated in PHP 5.3 (second version)

Karsten Dambekalns karsten at typo3.org
Thu Jan 22 20:44:45 CET 2009


Hi.

On 22.01.2009, at 19:59, Steffen Kamper wrote:
> $XclassParts = preg_split('/if \(defined\([\'"]TYPO3_MODE[\'"]\) &&
> \$TYPO3_CONF_VARS\[TYPO3_MODE\]\[[\'"]XCLASS[\'"]\]/',$fContent,2);
>
> could we extend this to match also $GLOBALS['TYPO3_CONF_VARS'] ?

No idea, I have no clue what the line is supposed to do. I simply  
adapted it :)

> -		$listArr = split(',|;|'.chr(10),$content);
> +		$listArr = preg_split('/[,;'.chr(10).']/',$content);
>
> there are other olaces using chr(10) as well, could we use \n there?

Yes, but then ' needs to be replaced by " - and I wanted to change as  
little as possible. If I was to change this, I'd probably rather  
change \n to chr(10) to avoid errors later on when " is optimized to  
'...

> -			$kw = split('[ ,]',$sw);
> +			$kw = preg_split('/[ ,]/',$sw);
>
> is this correct? I doubt that it should be preg_split('/\[ ,\]/',$sw);

No, it should split at space and comma, thus we need a character class  
here, as before (split uses ereg patterns)

> list($header,$content) = preg_split("/[\r\n\r\n]/", $res, 2);
>
> do we need the double quotes here? Why is windows linebreak used here,
> possible would also be \n\n

Yes, single quotes don't "expand" the \n to a newline but leave it as  
is (see also above). The windows linebreak is needed, this is from the  
htmlmail class if I am right - and in mails \r\n is defined by  
standards in quite some places.

> $reg = preg_split('/[[:space:]=]/',$tag_tmp,2);
>
> same as above, unescaped [] ?

No, split at space or equal sign.

> I think it could also be explode(' =', $tag_tmp, 2)

That would explode at ' =', but nopt at ' ' or '=' if the  
documentation and examples for explode() are not all wrong.

> comment above this line confuses me:
> // ... We look for the next ' ' or '>'

Well, at a few rare places there seem to be some comments not matching  
the code, probably copy-and-paste or refactoring errors.

> there are some more simular to my comments (chr(10), unescaped [])

In tried to be as careful as possible and believe I matched the  
original intention in all cases. If in doubt, feel free to check/ask/ 
test, that's exactly the purpose of this review process. :)

> Beside that, could you add spaces after the commas?

I was about to do it, but didn't know if it would be helpful and/or  
accepted. After all it would be mixing "cosmetics" with functional  
changes. If it is strongly requested I could do it, although doing it  
now (after the functional changes) is even more boring. "Must I, Miss  
Sophie?"

Regards,
Karsten
-- 
Karsten Dambekalns
Gimme Five!
http://typo3.org/gimmefive


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 312 bytes
Desc: This is a digitally signed message part
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20090122/c6950c41/attachment.pgp 


More information about the TYPO3-team-core mailing list