Adding a Select Box to section results in blank screen
A bug in 2.2, submitted by nickdunn on 05 January 2011
Announcement
Symphony's issue tracker has been moved to Github.
Issues are displayed here for reference only and cannot be created or edited.
Browse
Closed#465: Adding a Select Box to section results in blank screen
The field attempts to create a section association even when the “Dynamic Options” is set to “None” i.e. even when it doesn’t need to. The fix is to wrap createSectionAssociation
with a condition to check first:
$this->removeSectionAssociation($id); if ($this->get('dynamic_options')) { $this->createSectionAssociation(NULL, $id, $this->get('dynamic_options'), $this->get('show_association') == 'yes' ? true : false); }
In fact no, the fix shouldn’t go here. The old SB didn’t perform this check. So the fix goes into the Field::createSectionAssociation
method.
Pre 2.2 it was:
if($parent_section_id == NULL && !$parent_field_id) return false;
But it is now:
if(is_null($parent_section_id) && (is_null($parent_field_id)) return false;
But $parent_field_id
is not passed as NULL if there is no value — the field passes FALSE instead. So this check could be modified to be:
if(is_null($parent_section_id) && (is_null($parent_field_id) || !$parent_field_id)) return false;
So that both a NULL and FALSE value is checked.
This was probably changed by Brendan when he modified the section association bits and pieces.
Still not sure why it dies without trace though. My guess is the fact that NULL values are getting through to the query, the query against the DB itself dies and the MySQL class doesn’t handle it properly.
This does not fix the issue for me..
In fact, it also chokes if I use the dynamic options, so I think there is something else lurking around somewhere..
I have done some testing, and for me, the Symphony::Database()->insert($fields, 'sym_fields_' . $this->handle())
seems to cause the problem.
Have not yet figured out why there are no errors logged..
Ok, I found something. The Insert query tries to insert data into the row: ‘show_association’, while this row doesn’t exist.
Adding the row to the mysql table fixes the issue.
What I still find strange, though, is that the mysql error isn’t logged nor displayed. Has exception handling changed?
Ah good, my diagnosis was close:
My guess is the fact that NULL values are getting through to the query, the query against the DB itself dies and the MySQL class doesn’t handle it properly.
But…
Adding the row to the mysql table fixes the issue.
If you have installed from scratch then you should have the show_association
column. Did you use the default workspace? I didn’t, and I didn’t have to create the column manually.
- SB and SBL field tables have a column named
show_association
sym_sections_association
has a column namedhide_association
So the bug is in two parts:
- first of all, your install didn’t have the column — need to find out why
- secondly, even when you do have the column (I did), the error still occurs, so the above PHP fix is still required
Did you use the default workspace? I didn’t, and I didn’t have to create the column manually.
I don’t know if it’s useful, but I’ve got a fresh copy of Symphony 2.2.0beta (integration branch) + the default workspace (integration branch) and I have both sym_sections_association
and show_association
in the database.
Do you have show_association
in sym_sections_association
, and hide_association
in each SB and SBL field instance tables?
Do you have showassociation in symsectionsassociation, and hideassociation in each SB and SBL field instance tables?
_sections_association
->hide_association
_fields_select
->show_association
_fields_selectbox_link
->show_association
That’s good. I wonder why Huib did not have these.
Hadn’t seen this discussion… a few minutes ago I committed this fix. Does that solve the problem?
It works, but see my second comment above - the true fix should go into the Field class as this is the code that has changed. I think that method already handles the array so no need to loop. I figured it out by comparing with 2.1 code.
This issue is closed.
Create a new section. Add a SB. Save. You get a blank white screen, no errors logged.
Seems to be caused by the removeSectionAssociation/createSectionAssociation methods calls. Investigating…