Skip to content

Commit d4396ba

Browse files
authored
Fix studio not saving field properties correctly
1 parent 1a114a9 commit d4396ba

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

modules/ModuleBuilder/parsers/StandardField.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
99
*
1010
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
11-
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
11+
* Copyright (C) 2011 - 2024 SalesAgility Ltd.
1212
*
1313
* This program is free software; you can redistribute it and/or modify it under
1414
* the terms of the GNU Affero General Public License version 3 as published by the
@@ -119,17 +119,19 @@ public function addFieldObject(&$field)
119119
$this->baseField = get_widget($field->type) ;
120120
foreach ($field->vardef_map as $property => $fmd_col) {
121121
if ($property == "action" || $property == "label_value" || $property == "label"
122-
|| ((substr((string) $property, 0, 3) == 'ext' && strlen((string) $property) == 4))
122+
|| ((str_starts_with((string)$property, 'ext') && strlen((string) $property) == 4))
123+
// possible bug here... $property is often the same as $fmd_col, but not always. Maybe we should also add:
124+
// || ((str_starts_with((string)$fmd_col, 'ext') && strlen((string) $fmd_col) == 4))
125+
// ... but a thorough analysis of the consequences of this would be required.
123126
) {
124127
continue;
125128
}
126-
127-
// Bug 37043 - Avoid writing out vardef defintions that are the default value.
129+
130+
// Avoid writing out vardef definitions that are the default value, when possible.
131+
// Since isDefaultvalue() is quite limited, and doesn't handle all cases well,
132+
// sometimes we won't detect defaults and will store them anyway.
128133
if (isset($newDef[$property]) &&
129-
(
130-
(!isset($currdef[$property]) && !$this->isDefaultValue($property, $newDef[$property], $this->baseField))
131-
|| (isset($currdef[$property]) && $currdef[$property] != $newDef[$property])
132-
)
134+
!$this->isDefaultValue($property, $newDef[$property], $this->baseField)
133135
) {
134136
$this->custom_def[$property] =
135137
is_string($newDef[$property]) ? htmlspecialchars_decode($newDef[$property], ENT_QUOTES) : $newDef[$property];

0 commit comments

Comments
 (0)