[TYPO3-core] RFC #11876: stripSlashesOnArray creates references where you want copies

Ernesto Baschny [cron IT] ernst at cron-it.de
Tue Nov 3 21:38:19 CET 2009


Steffen Kamper schrieb:
> Hi Ernesto,
> 
> Ernesto Baschny [cron IT] schrieb:
>> I did and this is not correct. Every element in the loop gets assigned a
>> reference. This is I consider a PHP bug, and I doubt that they will
>> document that. :)
>>
>> Test this and uncomment the "unset" in the proper positions to see the
>> effect and that only the inside loop unset really trashes each reference.
>>
>> <?
>> ...snip...
>> ?>

> maybe i don't get it right. Testing the code there is no difference in
> result with all variants (no unset, inner/outer unset). Using this shows
> the result by reference:
> $arr = array('"a"', '"b"');
> Even then the array behaves correct. What do i miss?

You probably miss an affected PHP version. :) Debian-Etch's PHP 5.2.0 on
my side. With php eAccelerator if that matters. What is your flavour?

This are the original arrays:

orig:
array(2) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
}

copy:
array(2) {
  [0]=>
  &string(1) "X"
  [1]=>
  string(1) "b"
}

1) Here is the output of that code without any unset (current TYPO3 core
code):

orig (should be the same as the orig):
array(2) {
  [0]=>
  &string(1) "X"
  [1]=>
  string(1) "b"
}

2) And with the "inner" unset:

orig (should be the same as the orig):
array(2) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
}

3) And with the "outer" unset:

orig (should be the same as the orig):
array(2) {
  [0]=>
  &string(1) "X"
  [1]=>
  string(1) "b"
}

Here you can see that in 1 and 3 the original array way modified and
there are some bizarre "string references" where only strings used to be
(&string). Only in 2 the output is as expected, the unmodified orig array.

Cheers,
Ernesto


More information about the TYPO3-team-core mailing list