A problem with the selector variable

I discovered a Drupal bug that affects our selector variable.

The bug: when creating a new Boolean field like Selector, Content Type asks you which value you want to assign to “On value” and “Off value” (here:  https://edgeryders.eu/en/admin/structure/types/manage/post/fields/field_selector). The help text says default is “1” and “0” respectively. But this is not true: if you leave the fields blank, it will assign the empty string (“”) to both “On” and “Off value”. Once you have data in that field, you cannot change this setting anymore.

Conclusion:

  • All posts created since 2014-12-05  (included) show up as having Selector == ""
  • Posts created up to 2014-12-05 with Selector == "" are included in the Stewardship conversation.
  • Posts created up to 2014-12-05 with Selector == Null are not included in the Stewardship conversation.

What we need to do:

  1. Create a new field, call it SelectorNew.
  2. Set its values to "1" (On value) and "0" (Off value), writing those values explicitly in the respective fields.
  3. Write a SQL query that says (pseudocode)

for each post:

if not Selector(post) == Null AND creation_date < 2014-12-05:

SelectorNew(post) == “1”

At that point, we can delete Selector and keep working with the Assembl process on SelectorNew.

@Luca_Mearelli, can you do that? Or do you need @Matthias?

There is no problem

The bug is not as you describe. Instead: the database, in table field_data_field_selector, indeed contains the values 0 and 1 (numerical) according to the selection state of the checkbox, as documented in the field settings for the default case. Only the rendering of these into a string value when configuring the field_selector filter in the assembl_nodes view has a bug, rendering both as the empty string. This is cosmetic only, since the HTML source behind these is: <option value=“0”></option> and <option value=“1”></option>, respectively. So the filter works, its config interface is just not shown correctly. But the correct one of the two empty string options was selected already.

Result: all fine, no changes needed, keep on going. The assembl_nodes JSON file contains 118 nodes currently, which is all nodes having the “1” value assigned (as per SELECT COUNT( * ) FROM field_data_field_selector WHERE field_selector_value =1).

Debugging hint

BTW, for this and similar cases: To debug this properly without direct access to SQL, you can included the the field_data_field_selector values into the JSON output of the view temporarily. You’d have seen that there are indeed 0 and 1 as raw values in the database.