Bug #16179
closedFatal error with flexform fields in a database.
0%
Description
I have been able to produce this fatal error:
Fatal error: Cannot use string offset as an array in /home/www/cms/typo3_src-4.0/t3lib/class.t3lib_tcemain.php on line 1950
And I think it is a bug in the way the typo3 core handles the flexforms.
I have some events with a flexform field used to link price categories with a specific price in the specific event.
The XML data saved in this field could be this:
<T3FlexForms>
<data>
<sheet index="sDEF">
<language index="lDEF">
<field index="field_pricingsection">
<el index="el">
<section index="1">
<itemType index="field_pricingcontainer">
<el>
<field index="field_category">
<value index="vDEF">13</value>
</field>
<field index="field_price">
<value index="vDEF">0</value>
</field>
</el>
</itemType>
</section>
</el>
</field>
</language>
</sheet>
</data>
</T3FlexForms>
Then if I delete this element (consisting of a price category and a price), it only deletes this element not the section called field_pricingsection.
I think this is quite logical since it can delete the section unless it knows that there is not any other elements left in the section. The resulting XML is this:
<T3FlexForms>
<data>
<sheet index="sDEF">
<language index="lDEF">
<field index="field_pricingsection">
<el index="el">
</el>
</field>
</language>
</sheet>
</data>
</T3FlexForms>
Now, the issue arises when I try to create a price category and price relation again (like the first shown XML)
The error arises because typo3 can see that there is a section (it was not deleted when the last element was deleted), and then it accesses the content of this without checking that there is some content there.
/home/www/cms/typo3_src-4.0/t3lib/class.t3lib_tcemain.php on line 1950
I am not an expert in flexforms handling, but one solution would be to include a check for existing elements in dataValues_current around line 1950 in tcemain class.
(issue imported from #M3552)
Files