Use existing `import` method when saving PIP object
authorMatthias Schmidt <gravatronics@live.com>
Thu, 12 Jul 2018 17:12:11 +0000 (19:12 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 12 Jul 2018 17:12:11 +0000 (19:12 +0200)
See #2545

wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php

index 6e0ed9f4e179cb40b1b2d131783fb33ecf73f445..eaf339118fd8cad737a981837c3bcc3bcf38cdd6 100644 (file)
@@ -277,20 +277,18 @@ XML;
        protected function saveObject(\DOMElement $newElement, \DOMElement $oldElement = null) {
                $newElementData = $this->getElementData($newElement, true);
                
-               if ($oldElement === null) {
-                       call_user_func([$this->className, 'create'], $newElementData);
-               }
-               else {
+               $existingRow = [];
+               if ($oldElement !== null) {
                        $sqlData = $this->findExistingItem($this->getElementData($oldElement, true));
                        
                        $statement = WCF::getDB()->prepareStatement($sqlData['sql']);
                        $statement->execute($sqlData['parameters']);
                        
-                       $baseClass = call_user_func([$this->className, 'getBaseClass']);
-                       $itemEditor = new $this->className(new $baseClass(null, $statement->fetchArray()));
-                       $itemEditor->update($newElementData);
+                       $existingRow = $statement->fetchArray();
                }
                
+               $this->import($existingRow, $newElementData);
+               
                $this->postImport();
                
                if (is_subclass_of($this->className, IEditableCachedObject::class)) {