Problem/Motivation
The field purge cronjob fails after removing non-empty tablefield fields.
After deleting the field values from the DB, the error does not occur.
I had 50+ field values .
EDIT:
I had to delete the "field_deleted......." tables (for fields that were not shared by other bundles) AS WELL AS any remaining deleted data for the field that WAS shared by another bundle.
Deleting either one or the other did not help with the error, which means the field being shared is not a factor.
I am unfamiliar with the process of removing/purging fields, other factors might be relevant.
Steps to reproduce
(I'm afraid I don't have the time to double-check this now, but this is more-or less how it went)
- Create (two bundles of) a content entity type (message in my case) with a tablefield field.
- Create some entities with data in the tablefield field (for both)
- Remove the tablefield field (from one of the bundles)
- (I doubt that it's relevant, but at this point I exported the new config locally and imported in production.)
- The field purge cron job (field_cron() -> field_purge_batch()) fails with an error
At some point during the purge code the field is instantiated with its current value.
The setValue()
method in TablefieldItem
receives $values
as:
[
'value' => "serialized table data",
'format' => "format",
'caption' => "caption",
];
and does not properly process it.
An error occurs in array_key_exists in the block
elseif (empty($values['rebuild'])) {
array_key_exists(): Argument #2 ($array) must be of type array, string given
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes