From 59cb375dcdcbae745e737a6d2cd463778af6806c Mon Sep 17 00:00:00 2001 From: Hugo Peek Date: Sun, 14 Sep 2025 18:57:40 +0800 Subject: [PATCH 1/2] Reset unset tinyint values to default on build When resetting a tinyint value to its default (often 0), it is no longer added to the YAML file. This resulted in the field being ignored on other installs when running a build, and thus not receiving the updated value. Now, all tinyint fields that are NOT explicitly set in the YAML config will be reset to the default value. This ensures that things like enabling/disabling plugins or static templates will be properly applied on remote installations. This fixes #411. --- src/Command/BuildCommand.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Command/BuildCommand.php b/src/Command/BuildCommand.php index 76a9a97..7eef0e8 100644 --- a/src/Command/BuildCommand.php +++ b/src/Command/BuildCommand.php @@ -477,6 +477,23 @@ public function buildSingleObject($data, $type, $isConflictResolution = false) { $catName = $data['category']; $data['category'] = $this->getCategoryId($catName); } + + // Make sure default value is applied to empty tinyint fields + foreach ($object->_fieldMeta as $key => $value) { + if ($value['dbtype'] == 'tinyint') { + + // Skip fields that are explicitly set in YAML config + if (isset($data[$key])) continue; + + // Reset fields with a value other than the default + if (isset($value['default']) && $object->get($key) != $value['default']) { + if ($this->output->isVerbose()) { + $this->output->writeln("- Resetting $key field to default value for " . $object->get('name') . " object."); + } + $data[$key] = $value['default']; + } + } + } } $object->fromArray($data, '', true, true); From 7649d216746ca86c637e32461a726b12c8bdbbe5 Mon Sep 17 00:00:00 2001 From: Hugo Peek Date: Mon, 15 Sep 2025 15:15:53 +0800 Subject: [PATCH 2/2] Skip excluded fields when applying tinyint defaults --- src/Command/BuildCommand.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Command/BuildCommand.php b/src/Command/BuildCommand.php index 7eef0e8..5340a40 100644 --- a/src/Command/BuildCommand.php +++ b/src/Command/BuildCommand.php @@ -481,9 +481,10 @@ public function buildSingleObject($data, $type, $isConflictResolution = false) { // Make sure default value is applied to empty tinyint fields foreach ($object->_fieldMeta as $key => $value) { if ($value['dbtype'] == 'tinyint') { + $excludes = (isset($type['exclude_keys']) && is_array($type['exclude_keys'])) ? $type['exclude_keys'] : array(); - // Skip fields that are explicitly set in YAML config - if (isset($data[$key])) continue; + // Skip fields that are explicitly defined OR excluded in YAML config + if (isset($data[$key]) || in_array($key, $excludes)) continue; // Reset fields with a value other than the default if (isset($value['default']) && $object->get($key) != $value['default']) {