Fix property reset in ArticleAddForm::save()
authorMatthias Schmidt <gravatronics@live.com>
Thu, 9 Jun 2016 17:01:23 +0000 (19:01 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 9 Jun 2016 17:01:23 +0000 (19:01 +0200)
wcfsetup/install/files/lib/acp/form/ArticleAddForm.class.php

index 383eea327734f94e67bf1801fc4e5db5a0a278f4..4df62712a20e599fc437d62db35a369e9db276fe 100644 (file)
@@ -351,10 +351,12 @@ class ArticleAddForm extends AbstractForm {
                WCF::getTPL()->assign('success', true);
                
                // reset variables
-               $this->username = $this->publicationDate = '';
+               $this->publicationDate = '';
                $this->categoryID = 0;
                $this->publicationStatus = $this->enableComments = 1;
                $this->title = $this->teaser = $this->content = $this->images = $this->imageID = $this->tags = [];
+               
+               $this->setDefaultValues();
        }
        
        /**
@@ -364,13 +366,20 @@ class ArticleAddForm extends AbstractForm {
                parent::readData();
                
                if (empty($_POST)) {
-                       $this->username = WCF::getUser()->username;
-                       $dateTime = DateUtil::getDateTimeByTimestamp(TIME_NOW);
-                       $dateTime->setTimezone(WCF::getUser()->getTimeZone());
-                       $this->time = $dateTime->format('c');
+                       $this->setDefaultValues();
                }
-       }       
-               
+       }
+       
+       /**
+        * Sets the default values of properties.
+        */
+       protected function setDefaultValues() {
+               $this->username = WCF::getUser()->username;
+               $dateTime = DateUtil::getDateTimeByTimestamp(TIME_NOW);
+               $dateTime->setTimezone(WCF::getUser()->getTimeZone());
+               $this->time = $dateTime->format('c');
+       }
+       
        /**
         * @inheritDoc
         */