SpecialBlock: Simplify HTMLForm submit callback handling
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 27 Jul 2015 14:23:24 +0000 (16:23 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 27 Jul 2015 17:14:32 +0000 (17:14 +0000)
We can just use onSubmit() instead of our own custom stuff.
The comment stating that we can't is wrong; perhaps it used
to be correct, back when it was written.

Change-Id: Ib18fb7292a67b471e9ad13cf38038287b9bd2bd2

includes/specials/SpecialBlock.php

index b4d4220..e0f35c6 100644 (file)
@@ -97,7 +97,6 @@ class SpecialBlock extends FormSpecialPage {
        protected function alterForm( HTMLForm $form ) {
                $form->setWrapperLegendMsg( 'blockip-legend' );
                $form->setHeaderText( '' );
-               $form->setSubmitCallback( array( __CLASS__, 'processUIForm' ) );
                $form->setSubmitDestructive();
 
                $msg = $this->alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit';
@@ -597,17 +596,8 @@ class SpecialBlock extends FormSpecialPage {
        }
 
        /**
-        * Submit callback for an HTMLForm object, will simply pass
-        * @param array $data
-        * @param HTMLForm $form
-        * @return bool|string
-        */
-       public static function processUIForm( array $data, HTMLForm $form ) {
-               return self::processForm( $data, $form->getContext() );
-       }
-
-       /**
-        * Given the form data, actually implement a block
+        * Given the form data, actually implement a block. This is also called from ApiBlock.
+        *
         * @param array $data
         * @param IContextSource $context
         * @return bool|string
@@ -962,11 +952,11 @@ class SpecialBlock extends FormSpecialPage {
        /**
         * Process the form on POST submission.
         * @param array $data
+        * @param HTMLForm $form
         * @return bool|array True for success, false for didn't-try, array of errors on failure
         */
-       public function onSubmit( array $data ) {
-               // This isn't used since we need that HTMLForm that's passed in the
-               // second parameter. See alterForm for the real function
+       public function onSubmit( array $data, HTMLForm $form = null ) {
+               return self::processForm( $data, $form->getContext() );
        }
 
        /**