saveField passes a limited number of fields to the afterSave methods which means AggregateCacheBehavior cannot properly update related models as it is not guaranteed to have all the keys it needs.
To fix this code was added to AggregateCacheBehavior::afterSave to check the current $model->data against $model->schema to make sure all the fields were available.
However, AggregateCacheBehavior::afterSave is doing array_diff_key in the wrong order - it needs to compare the current data array against the full schema to make sure all the fields are in there. It is currently comparing the schema against the current data array - which wrongly gives the current data array priority over schema, thus rendering the fix useless.
AggregateCacheBehavior::afterSave needs to be modified to compare $model->data against $model->schema (reverse current order).
saveField passes a limited number of fields to the afterSave methods which means AggregateCacheBehavior cannot properly update related models as it is not guaranteed to have all the keys it needs.
To fix this code was added to AggregateCacheBehavior::afterSave to check the current $model->data against $model->schema to make sure all the fields were available.
However, AggregateCacheBehavior::afterSave is doing array_diff_key in the wrong order - it needs to compare the current data array against the full schema to make sure all the fields are in there. It is currently comparing the schema against the current data array - which wrongly gives the current data array priority over schema, thus rendering the fix useless.
AggregateCacheBehavior::afterSave needs to be modified to compare $model->data against $model->schema (reverse current order).