[TYPO3-core] RFC #17489: [Performance] Improve t3lib_extMgm::addToAllTCAtypes performance

JoH asenau info at cybercraft.de
Fri Feb 11 12:00:04 CET 2011


>> I also fear, that
>> if (strpos($needle, $insertionPosition) !== FALSE)
>> does not do the same as
>> $positions = t3lib_div::trimExplode(',', $insertionPosition, TRUE);
>> if (in_array($needle, $positions)) {
>>
>> Consider this example:
>> $list = 'header,header_layout,bodytext';
>> $insertionPosition = 'header';
>>
>> If I'm not wrong, the new field would be inserted twice, because strpos
>> matches for "header" and "header_layout".
>>
>> But I did not test this yet.
>>
>> Nevertheless -1 by reading for now.
>
> You are right with both issues, so I will come up with a fixed v7 later.

First I thought your second example would not be working but then I 
checked the code again and found out that actually the problem is the 
other way around:

The field will be inserted twice when there are two existing fields that 
partially match the name of the new field.

$list = 'image,text';
$insertionPosition = 'before:image_text';

In this case "whatever" would be inserted twice since there were two 
matching field names in the position list.

So what we have to do is to append a comma before comparing the strings:

The check would be:

"image," and "text," against "before:image_text,"

Since we have to prepend and append strings anyway this should still be 
faster than in_array, but maybe Steffen G. can confirm that by measuring 
the attached patch against his last results.

The first issue with the missing return has been fixed as well.

Still it might be possible to remove the whole construct in favour of a 
sophisticated preg_replace, but that would be a task for 4.6 or later I 
guess.

Cheers

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 17489_v7.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20110211/288425bb/attachment.asc>


More information about the TYPO3-team-core mailing list