ParamValidator: Flag as unstable for 1.34
[lhc/web/wiklou.git] / includes / specials / SpecialNewSection.php
index b503141..6c328da 100644 (file)
@@ -24,7 +24,7 @@ class SpecialNewSection extends RedirectSpecialPage {
        public function __construct() {
                parent::__construct( 'NewSection' );
                $this->mAllowedRedirectParams = [ 'preloadtitle', 'nosummary', 'editintro',
-                       'preload', 'preloadparams[]', 'summary' ];
+                       'preload', 'preloadparams', 'summary' ];
        }
 
        /**
@@ -43,6 +43,7 @@ class SpecialNewSection extends RedirectSpecialPage {
        protected function showNoRedirectPage() {
                $this->setHeaders();
                $this->outputHeader();
+               $this->addHelpLink( 'Help:New section' );
                $this->showForm();
        }
 
@@ -52,6 +53,7 @@ class SpecialNewSection extends RedirectSpecialPage {
                                'type' => 'text',
                                'name' => 'page',
                                'label-message' => 'newsection-page',
+                               'required' => true,
                        ],
                ], $this->getContext(), 'newsection' );
                $form->setSubmitTextMsg( 'newsection-submit' );
@@ -60,7 +62,12 @@ class SpecialNewSection extends RedirectSpecialPage {
        }
 
        public function onFormSubmit( $formData ) {
-               $page = $formData['page'];
+               $title = $formData['page'];
+               try {
+                       $page = Title::newFromTextThrow( $title );
+               } catch ( MalformedTitleException $e ) {
+                       return Status::newFatal( $e->getMessageObject() );
+               }
                $query = [ 'action' => 'edit', 'section' => 'new' ];
                $url = $page->getFullUrlForRedirect( $query );
                $this->getOutput()->redirect( $url );