Issue Bug Closed

#16179Fatal error with flexform fields in a database.

Morten Hansen 05/24/06, 23:43 updated 05/14/08, 10:01

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:

<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<t3flexforms><br> <data><br> <sheet index="sDEF"><br> <language index="lDEF"><br> <field index="field_pricingsection"><br> <el index="el"><br> <section index="1"><br> <itemtype index="field_pricingcontainer"><br> <el><br> <field index="field_category"><br> <value index="vDEF">13</value><br> </field><br> <field index="field_price"><br> <value index="vDEF">0</value><br> </field><br> </el><br> </itemtype><br> </section><br> </el><br> </field><br> </language><br> </sheet><br> </data><br></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:

<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<t3flexforms><br> <data><br> <sheet index="sDEF"><br> <language index="lDEF"><br> <field index="field_pricingsection"><br> <el index="el"><br> </el><br> </field><br> </language><br> </sheet><br> </data><br></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)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.