|
8 | 8 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
|
9 | 9 | *
|
10 | 10 | * 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. |
12 | 12 | *
|
13 | 13 | * This program is free software; you can redistribute it and/or modify it under
|
14 | 14 | * the terms of the GNU Affero General Public License version 3 as published by the
|
@@ -119,17 +119,19 @@ public function addFieldObject(&$field)
|
119 | 119 | $this->baseField = get_widget($field->type) ;
|
120 | 120 | foreach ($field->vardef_map as $property => $fmd_col) {
|
121 | 121 | 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. |
123 | 126 | ) {
|
124 | 127 | continue;
|
125 | 128 | }
|
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. |
128 | 133 | 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) |
133 | 135 | ) {
|
134 | 136 | $this->custom_def[$property] =
|
135 | 137 | is_string($newDef[$property]) ? htmlspecialchars_decode($newDef[$property], ENT_QUOTES) : $newDef[$property];
|
|
0 commit comments