Prevent overwriting of some user profile field settings by updates
authorMarcel Werk <burntime@woltlab.com>
Fri, 27 Dec 2024 14:10:03 +0000 (15:10 +0100)
committerMarcel Werk <burntime@woltlab.com>
Fri, 27 Dec 2024 14:10:03 +0000 (15:10 +0100)
ref https://www.woltlab.com/community/thread/310192-voreinstellung-benutzerprofilfeld-bearbeiten-wird-beim-update-nicht-%C3%BCbernommen/

wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php

index ad2893f987a1c21d29e39fca45a60322b3da4f99..19c89b1deed85215d39acc9dba5aadc8988cfd34 100644 (file)
@@ -118,7 +118,7 @@ class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallat
     {
         // default values
         $optionName = $optionType = $validationPattern = $outputClass = $selectOptions = $enableOptions = $permissions = $options = '';
-        $required = $editable = $visible = $searchable = $isDisabled = $askDuringRegistration = 0;
+        $editable = $visible = $isDisabled = 0;
         $defaultValue = $showOrder = null;
 
         // get values
@@ -134,21 +134,12 @@ class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallat
         if (isset($option['validationpattern'])) {
             $validationPattern = $option['validationpattern'];
         }
-        if (isset($option['required'])) {
-            $required = \intval($option['required']);
-        }
-        if (isset($option['askduringregistration'])) {
-            $askDuringRegistration = \intval($option['askduringregistration']);
-        }
         if (isset($option['editable'])) {
             $editable = \intval($option['editable']);
         }
         if (isset($option['visible'])) {
             $visible = \intval($option['visible']);
         }
-        if (isset($option['searchable'])) {
-            $searchable = \intval($option['searchable']);
-        }
         if (isset($option['showorder'])) {
             $showOrder = \intval($option['showorder']);
         }
@@ -200,12 +191,9 @@ class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallat
             'validationPattern' => $validationPattern,
             'selectOptions' => $selectOptions,
             'enableOptions' => $enableOptions,
-            'required' => $required,
-            'askDuringRegistration' => $askDuringRegistration,
             'editable' => $editable,
             'visible' => $visible,
             'outputClass' => $outputClass,
-            'searchable' => $searchable,
             'showOrder' => $showOrder,
             'permissions' => $permissions,
             'options' => $options,
@@ -213,6 +201,16 @@ class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallat
             'originIsSystem' => 1,
         ];
 
+        if (isset($option['required'])) {
+            $data['required'] = \intval($option['required']);
+        }
+        if (isset($option['askduringregistration'])) {
+            $data['askDuringRegistration'] = \intval($option['askduringregistration']);
+        }
+        if (isset($option['searchable'])) {
+            $data['searchable'] = \intval($option['searchable']);
+        }
+
         // update option
         if (!empty($result['optionID']) && $this->installation->getAction() == 'update') {
             $userOption = new UserOption(null, $result);