44061[BUGFIX] Prevent PHP warning when trying to loop over null
Commit message
Review
-
Code review CR +2
- Stefan Neufeind +2
- Daniel Goerz +1
- Stephan Großberndt +1
- Oliver Hader +1
-
Verified V +2
- Stefan Neufeind +2
Issues 1
Files 1
Review log 18
-
Xavier Perseguers uploaded patch set 1 10/14/15, 15:10
-
Daniel Goerz updated the commit message in patch set 2 10/14/15, 16:59
-
Daniel Goerz voted on patch set 2 CR +1 10/14/15, 16:59
-
Stephan Großberndt voted on patch set 2 CR +1 10/14/15, 17:35
-
Christian Kuhn voted on patch set 2 CR +1 V +1 10/15/15, 09:04
-
Markus Klein commented on patch set 2 CR -1 10/15/15, 09:21
-
Xavier Perseguers commented on patch set 2 10/15/15, 09:30
will have to further debug, actually this happens with EXT:image_autoresize where I'm currently in the process of making the configuration wizard work again, using a "standalone" version of the (new) FormEngine. Feel free to help :) -
Xavier Perseguers commented on patch set 2 10/15/15, 13:15
OK, by further debugging, I found the root cause. Previously TCEforms was accepting a comma-separated list of values. FormEngine now expects an actual array. I'd say that to keep compatibility, we "could" trimExplode here in case value is not an array (would then work for both empty value = no items selected) or comma-separated values. I don't know if this may actually happen since the whole business logic was refactored. I have the case because of my virtual TCA in EXT:image_autoresize but since I have to deal with different behaviour in 6.2-7.4 and 7.5+, I could easily "trimExplode" for 7.5+ before invoking FormEngine rendering process. @Christian please either answer here or discuss with me what is best on your side. You better know if you forgot about this edge-case when refactoring or if my use case cannot happen in real life scenario. -
Xavier Perseguers commented on patch set 2 10/15/15, 13:35
Please see my "adaptation" in https://review.typo3.org/#/c/44062/5/mod1/index.php lines 100-106 -
Christian Kuhn commented on patch set 2 CR 0 V 0 10/15/15, 14:31
hmm, data provider should take care that render part always has an array for values. i'd rather like to keep that and not introduce a trimExplode here. -
Xavier Perseguers abandoned the change 10/15/15, 15:18
My custom data provider will take care of that. -
Xavier Perseguers restored the change 10/19/15, 08:05
The problem still happens with FlexForm-based children, for the placeholder of a default new element. The preparation of the faulty value (this time "null") is done by \TYPO3\CMS\Backend\Form\Container\FlexFormElementContainer around line 118. For a select field based on fe_groups table (nothing special), the configuration looks like that: <config type="array"> <type>select</type> <foreign_table>be_groups</foreign_table> <foreign_table_where>ORDER BY be_groups.title</foreign_table_where> <size>5</size> <minitems>0</minitems> <maxitems>99</maxitems> <autoSizeMax>10</autoSizeMax> </config> but the initialization code goes to the initialization line `$fakeParameterArray['itemFormElValue'] = $fakeParameterArray['fieldConf']['config']['default'];` since `$flexFormRowData` is an empty array (remember, this is an empty new element to be added as new child if requested). Since 'select' does not have a "default" value (which is empty), the initialization line puts null there. It is not possible to test for null and put an array instead because this initialization line is the same for many types and could once be a string another time an integer, ... and in my case an array so the correct solution (and actually the one which makes most sense since we should never trust outside code to do the job correctly, is in fact simply to ensure we loop over an array. -
Xavier Perseguers commented on patch set 2 10/19/15, 08:12
SelectMultipleSideBySideElement.php:66ReplyNot possible in all cases, see my explanation as I restored this patch from the abandoned state. @Christian: it's perfectly fine to expect the data provider to do its job, but the initialization code still may produce "null" (not an empty string as I had the case before), and it just makes sense to NOT trust code outside of a function and ensure we effectively loop over an array since it can happen. Not speaking about adding more business logic such as trimExploding a string here, I totally agree this would be the wrong place and not the business of this method. -
Oliver Hader voted on patch set 2 CR +1 10/19/15, 08:17
-
Stefan Neufeind commented on patch set 2 CR +1 10/19/15, 10:40
@Markus: Maybe reconsider your -1? -
Markus Klein voted on patch set 2 CR 0 10/19/15, 19:22
-
Stefan Neufeind voted on patch set 2 CR +2 V +2 10/19/15, 21:17
-
Stefan Neufeind merged patch set 2 10/19/15, 21:17
SelectMultipleSideBySideElement.php:66