tributemedia / tpc_userpoints_ext

Extends Userpoints and dependencies for the purpose of TPC Resident Rewards Program.
0 stars 0 forks source link

Exception On Cache Clear #19

Open AntonioXIII opened 4 years ago

AntonioXIII commented 4 years ago

When attempting to clear the cache, the site errors out with the following log:

Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException: A list field (field_tpc_re_actions) with existing data cannot have its keys changed. in options_field_storage_config_update_forbid() (line 116 of /srv/bindings/1410d1ec125d4a9aa5ed41919346ab48/code/web/core/modules/options/options.module).
AntonioXIII commented 4 years ago

The error turned out to be caused by adding new transaction operations. These operations were not apart of the allowed_values setting on the field storage config for the actions field on the report entry entity. They were being set statically, which you're basically only allowed to do when the field has no data, hence the exception.

I fixed this error by specifying the following setting in the field storage config:

allowed_values_function: 'monthlyReportEntryAllowedValues'

This specifies a function defined in the .module file that returns a dynamic list of allowed values, instead of the static one used before.

I tested this solution by removing all entries, specifying the above config and implementing the function, and then filled out a report. I then added a new transaction operation, filled out another form, and then attempted to clear the cache. No error occurred as it had before.

This error appears to be fixed, so I'll mark ready for testing.