Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP8 issue with several tripal fields #116

Open
dsenalik opened this issue Nov 29, 2022 · 3 comments
Open

PHP8 issue with several tripal fields #116

dsenalik opened this issue Nov 29, 2022 · 3 comments

Comments

@dsenalik
Copy link
Contributor

dsenalik commented Nov 29, 2022

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'] = [];

@dsenalik
Copy link
Contributor Author

dsenalik commented Nov 29, 2022

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.

@dsenalik
Copy link
Contributor Author

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

@dsenalik
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant