core: FieldFillListener.postLoad buggy? ("explode() expects parameter 2 to be string, null given")
We have content with a collection of sets like this:
slides:
name: Slides
singular_name: Slide
....
fields:
.....
popups:
type: collection
fields:
afbeelding:
type: set
fields:
label:
type: text
weergave:
type: select
values: [ 'beeldvullend', 'kleine tooltip' ]
afbeelding:
type: image
tekst:
type: set
....
The nested select field has been added after content had already been created. (I don’t know if this is relevant)
Now when we edit content and add a ‘popup’ the editor will get a 500 error:
TypeError:
explode() expects parameter 2 to be string, null given
at vendor/bolt/core/src/Twig/FieldExtension.php:255
at explode('/', null)
(vendor/bolt/core/src/Twig/FieldExtension.php:255)
at Bolt\Twig\FieldExtension->selectOptionsContentType(object(SelectField))
(vendor/bolt/core/src/Twig/FieldExtension.php:213)
at Bolt\Twig\FieldExtension->selectOptions(object(SelectField))
(var/cache/dev/twig/35/354d023db4d40905d60ed64367dda109f3741095dcecb06c66f49c16938b7c5e.php:50)
at __TwigTemplate_3fdcff874b050495e998b65d907cdc8f9af6d1d08c8e6fbcbdbfcc5e1a9dae4c->doDisplay(array('compound_label' => 'Woorden', 'id' => 'field-popups-woorden-1-weergave', 'field' => object(SelectField), 'name' => 'collections[popups][woorden][1][weergave]', 'record' => object(Content), 'include_id' => true, 'app' => object(AppVariable), 'config' => object(Config), 'defaultLocale' => 'en'), array('field' => array(object(__TwigTemplate_3fdcff874b050495e998b65d907cdc8f9af6d1d08c8e6fbcbdbfcc5e1a9dae4c), 'block_field')))
(vendor/twig/twig/src/Template.php:394)
at Twig\Template->displayWithErrorHandling(array('compound_label' => 'Woorden', 'id' => 'field-popups-woorden-1-weergave', 'field' => object(SelectField), 'name' => 'collections[popups][woorden][1][weergave]', 'record' => object(Content), 'include_id' => true, 'app' => object(AppVariable), 'config' => object(Config), 'defaultLocale' => 'en'), array('field' => array(object(__TwigTemplate_3fdcff874b050495e998b65d907cdc8f9af6d1d08c8e6fbcbdbfcc5e1a9dae4c), 'block_field')))
(vendor/twig/twig/src/Template.php:367)
at Twig\Template->display(array('compound_label' => 'Woorden', 'id' => 'field-popups-woorden-1-weergave', 'field' => object(SelectField), 'name' => 'collections[popups][woorden][1][weergave]', 'record' => object(Content), 'include_id' => true), array())
(vendor/twig/twig/src/TemplateWrapper.php:47)
...
This error was really hard to diagnose, but in the end it boiled down to an issue caused by the order of initialization of the fields. Somehow I did end up with the select field having a higher id than that of the set it is in, but the set having lower id than the collection it is part of. This causes issues in the case of our select field, because the logic for combining content (from db) with configuration (from contenttypes.yml) needs a full list of parents (of parents of parents…) but our id combination combined with the initialization order of Doctrine results in one parent missing, with results is no ‘values’ found for the select, which results in some part of FieldExtension.php ‘thinking’ it must be a select that uses other content types, and that function finally breaking horribly because the ‘values’ is in fact ‘null’.
I think that even if in general the order of the ids is preventing this, it should not be programmed in a way that is dependent on the id order. I might have a fix, but that one probably should be checked thoroughly.
(I’ll expand this later and/or submit a PR)
Details
| Question | Answer |
|---|---|
| Relevant Bolt Version | 5.1.2 |
| Install type | Composer install |
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (16 by maintainers)
hi @andysh-uk while your issue might be related (I really don’t know) it could also be something completely different. It’s better to file a separate issue.