statonlab/tripal_manage_analyses

PHP8 issue with several tripal fields

Opened this issue · 3 comments

Four tripal fields from this module in the load() function initialize the field with this code:
$entity->{$field}['und'][0]['value'] = NULL;

When editing e.g. an organism and then saving, the ero__nucleic_acid_library field generates a white screen of death
The website encountered an unexpected error. Please try again later.
and the first error in the log is
Warning: foreach() argument must be of type array|object, null given in tripal_chado_field_storage_write_table() (line 185 of .../sites/all/modules/tripal/tripal_chado/includes/tripal_chado.field_storage.inc).

PHP8 is more strict about things, the problem can be resolved by changing the initialization code to
$entity->{$field}['und'][0]['value'] = [];

Some other fields use something like this

    //  We should load in the data here.
    //  As a stopgap, we simply use the data loaded by the parent field in the formatter instead.
    $entity->local__child_properties['und'][0]['value'] = TRUE;

This also causes WSOD on saving e.g. a gene (feature) with the local__child_properties field.
Again, changing to an empty array fixes this error but probably breaks the field. It should really be fixed to load data in the load() function so web services work also. *edit change it to [TRUE] like local__phylotree_link does, and everything works as before.

And finally some fields do not do the initialization at all and cause a similar error, adding the initialization fixes this.

P.S. Some of the non-functional widgets cause errors too, and since they can't work because of the missing load() function data, make them non-functional stubs.