| @@ -11,9 +11,9 @@ | ||
| 11 | 11 | */ |
| 12 | 12 | abstract class Model { |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * List of data fields keyed to their current values. Will be initialised with default values. | |
| 15 | + * List of data fields keyed to their current values. Will be initialized with default values. | |
| 16 | 16 | * |
| 17 | 17 | * @var array<string, mixed> |
| 18 | 18 | */ |
| 19 | 19 | protected array $fields; |
| @@ -90,9 +90,13 @@ | ||
| 90 | 90 | public function get_modified_fields(): array { |
| 91 | 91 | return array_filter( |
| 92 | 92 | $this->get_fields(), |
| 93 | 93 | function ( $value, $field ) { |
| 94 | - return $value && $value !== static::$default_values[ $field ]; | |
| 94 | + // The field list includes aliases, which have no entry of their own | |
| 95 | + // in the defaults. Compare against the field an alias resolves to, | |
| 96 | + // so reading a snippet built from alias keys does not warn. | |
| 97 | + $default = static::$default_values[ static::resolve_field_name( $field ) ] ?? null; | |
| 98 | + return $value && $value !== $default; | |
| 95 | 99 | }, |
| 96 | 100 | ARRAY_FILTER_USE_BOTH |
| 97 | 101 | ); |
| 98 | 102 | } |