Bug #41487
closedstdWrap executed twice on GIFBUILDER object properties
100%
Description
This is an intentional duplicate of #25189 to boil down all the findings and discussions and make it easier to see the basic problem and its solution.
Problem¶
The result of the following TS is a GIF containing the text AAfooBB instead of AfooB.
page.100 = IMAGE page.100 { file = GIFBUILDER file { 10 = TEXT 10{ offset = 0,20 text = foo text.wrap = A|B } } }
Deeper analysis of the bug shows that all stdWraps of all properties of TEXT objects in GIFBUILDER are done twice!
This double stdWrapping affects GIFBUILDER as well as GMENU objects.
The bug is present in all current versions from 4.5 LTS to 4.7.
Background¶
This bug was introduced during the extensive overhaul of stdWrap from TYPO3 v4.4 to v4.5.
In the course of this overhaul a great number of stdWrap calls that were spread all over class.tslib_gifbuilder.php have been condensed down into one central stdWrap loop in the tslib_gifBuilder->make() method.
Additionally an identical stdWrap loop was added to tslib_gifBuilder->checkTextObj(). checkTextObj is ONLY called for TEXT objects (as its name implies). checkTextObj() is executed much earlier in the GIFBILDER process than make(), and the reason for having a preliminary stdWrapping there-in is to provide correctly wrapped values for the initial math of all the properties of TEXT objects (like the text width and so on). So this exception is definitely necessary.
In the final make() function the stdWrap loop is executed again for ALL object types. This results in a double wrapping for all TEXT objects.
Solution¶
The stdWrapping in make() should happen only for objects that are non-TEXT, as TEXT objects have already been stdWrapped in checkTextObj(). An additional if-condition around the stdWrap loop in make() solves the bug easily (see attached patch).
Files