PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
← All changes | php/Model/Model.php +6 -2 3.10.04.0.0-beta.2 View file →
@@ -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 }