Fix showOrder handling of smiley PIP GUI
authorMatthias Schmidt <gravatronics@live.com>
Sat, 17 Nov 2018 09:37:51 +0000 (10:37 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 17 Nov 2018 09:37:51 +0000 (10:37 +0100)
See #2545

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

index 9685b20248ff303d76d0e6760902727d149cf323..25ca849228036d8f2ff4f4ccf6e9db23ccf804d4 100644 (file)
@@ -238,7 +238,6 @@ class SmileyPackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                $optionalElements = [
                        'aliases' => 'aliases',
                        'smileyPath2x' => 'path2x',
-                       'showOrder' => 'showOrder'
                ];
                foreach ($optionalElements as $arrayKey => $elementName) {
                        $child = $element->getElementsByTagName($elementName)->item(0);
@@ -246,17 +245,21 @@ class SmileyPackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                                $data[$arrayKey] = $child->nodeValue;
                        }
                        else {
-                               if ($arrayKey === 'showOrder') {
-                                       if ($this->editedEntry === null) {
-                                               $data[$arrayKey] = $this->getShowOrder(null);
-                                       }
-                               }
-                               else {
-                                       $data[$arrayKey] = '';
-                               }
+                               $data[$arrayKey] = '';
                        }
                }
                
+               $showOrder = $element->getElementsByTagName('showorder')->item(0);
+               if ($showOrder !== null) {
+                       $data['showOrder'] = $showOrder->nodeValue;
+               }
+               if ($saveData && $this->editedEntry === null) {
+                       // only set explicit showOrder when adding new menu item
+                       $data['showOrder'] = $this->getShowOrder(
+                               $data['showOrder'] ?? null
+                       );
+               }
+               
                return $data;
        }