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

Ernesto Baschny [cron IT] ernst at cron-it.de
Tue Nov 3 17:35:02 CET 2009


Hi,

this indeed was also affecting the Install Tool people in #12342. I've
already got two +1 by testing in the bug tracker (Sebastian Schindler
and Dirk Diebel), and would welcome one core devel to review it by reading.

This should be "in" for 4.3-beta3 and also for a 4.2.11 release because
it solves one of the regressions of 4.2.10!

Thanks!

Cheers,
Ernesto

Ernesto Baschny [cron IT] schrieb:
> Hi,
> 
> please note that this might be also affecting the inglorious bug #12342
> ("Update required tables COMPARE doesn't work in 4.2.10") [1]
> 
> So please test also this fix with that Install Tool problem and confirm
> here if it solves the problem.
> 
> Cheers,
> Ernesto
> 
> [1] http://bugs.typo3.org/view.php?id=12342
> 
> Ernesto Baschny [cron IT] schrieb:
>> Hi,
>>
>> this is a SVN patch request.
>>
>> Type: Bugfix
>>
>> Branches: TYPO3_4-2, trunk
>>
>> BT reference: http://bugs.typo3.org/view.php?id=11876
>>
>> Problem:
>> In newer TYPO3 versions the class t3lib_div::stripSlashesOnArray has
>> been optimized for performance, using a foreach loop where it used to be
>> a while loop. The new version works on references instead of copying the
>> array.
>>
>> After calling this function on a normal array, the array itself contains
>> only references to the values it contained before. This ist quite ugly,
>> cause you can't work on a copy without changing the original data any more.
>>
>> Issue might arise on any extension that makes use of t3lib_div::_GP. Bug
>> was first noticed when trying to save mm-table-relations using
>> sr_feuser_register:
>>
>> here:
>>                 function parseOutgoingData($origArr = array()) {
>>   (...)
>>                         $parsedArr = $origArr;
>>
>> $parsedArr is a COPY of our $this->dataArr, but it will modify the
>> values from the original dataArr.
>>
>>
>> Proposed Solution:
>> If you unset the reference at the end of foreach, you can go on using
>> the array as before. This is recommended to do by the php.net
>> documentation (in a big red "Warning" box) when using references in a
>> "foreach" loop.
>>
>>
>> How to reproduce:
>> Since this is pretty difficult to test, attached to the bug tracker is a
>> very simple plugin which can be added to a page and it will explain and
>> demonstrate the bug in "action".
>>
>> Trouble was introduced in rev.3216 (feature #6037):
>> http://forge.typo3.org/repositories/revision/typo3v4-core/3216 [^]
>>
>> So it was first included in 4.2.0beta2.
>>
>> Cheers,
>> Ernesto
>>


More information about the TYPO3-team-core mailing list