Remove execute() from Action and subclasses
authorwithoutaname <drevitchi@gmail.com>
Tue, 15 Jul 2014 18:53:50 +0000 (11:53 -0700)
committerwithoutaname <drevitchi@gmail.com>
Wed, 16 Jul 2014 21:03:43 +0000 (14:03 -0700)
Since show() is always the preferred entry point, this is never used
nor implemented properly.

Change-Id: I5fde4bbd420a6695b01fb9220542fd3b49060675

RELEASE-NOTES-1.24
includes/actions/Action.php
includes/actions/FormAction.php
includes/actions/FormlessAction.php

index dc946e4..f9280fc 100644 (file)
@@ -245,6 +245,7 @@ changes to languages because of Bugzilla reports.
 * Removed ResourceLoaderGetStartupModules hook. (deprecated since 1.23)
 * Removed getFormFields(), onSubmit() and onSuccess() from FormlessAction, as
   these were meant specifically for FormAction instead.
+* Removed Action::execute().
 
 ==== Renamed classes ====
 * CLDRPluralRuleConverter_Expression to CLDRPluralRuleConverterExpression
index d4b08b2..839d0ed 100644 (file)
@@ -360,10 +360,4 @@ abstract class Action {
         * @throws ErrorPageError
         */
        abstract public function show();
-
-       /**
-        * Execute the action in a silent fashion: do not display anything or release any errors.
-        * @return bool whether execution was successful
-        */
-       abstract public function execute();
 }
index 7477d11..c6fcdde 100644 (file)
@@ -121,48 +121,4 @@ abstract class FormAction extends Action {
                        $this->onSuccess();
                }
        }
-
-       /**
-        * @see Action::execute()
-        *
-        * @param array|null $data
-        * @param bool $captureErrors
-        * @throws ErrorPageError|Exception
-        * @return bool
-        */
-       public function execute( array $data = null, $captureErrors = true ) {
-               try {
-                       // Set a new context so output doesn't leak.
-                       $this->context = clone $this->getContext();
-
-                       // This will throw exceptions if there's a problem
-                       $this->checkCanExecute( $this->getUser() );
-
-                       $fields = array();
-                       foreach ( $this->fields as $key => $params ) {
-                               if ( isset( $data[$key] ) ) {
-                                       $fields[$key] = $data[$key];
-                               } elseif ( isset( $params['default'] ) ) {
-                                       $fields[$key] = $params['default'];
-                               } else {
-                                       $fields[$key] = null;
-                               }
-                       }
-                       $status = $this->onSubmit( $fields );
-                       if ( $status === true ) {
-                               // This might do permanent stuff
-                               $this->onSuccess();
-                               return true;
-                       } else {
-                               return false;
-                       }
-               }
-               catch ( ErrorPageError $e ) {
-                       if ( $captureErrors ) {
-                               return false;
-                       } else {
-                               throw $e;
-                       }
-               }
-       }
 }
index 7b3a714..f61fc97 100644 (file)
@@ -43,35 +43,4 @@ abstract class FormlessAction extends Action {
 
                $this->getOutput()->addHTML( $this->onView() );
        }
-
-       /**
-        * Execute the action silently, not giving any output.  Since these actions don't have
-        * forms, they probably won't have any data, but some (eg rollback) may do
-        * @param array $data Values that would normally be in the GET request
-        * @param bool $captureErrors Whether to catch exceptions and just return false
-        * @throws ErrorPageError|Exception
-        * @return bool Whether execution was successful
-        */
-       public function execute( array $data = null, $captureErrors = true ) {
-               try {
-                       // Set a new context so output doesn't leak.
-                       $this->context = clone $this->getContext();
-                       if ( is_array( $data ) ) {
-                               $this->context->setRequest( new FauxRequest( $data, false ) );
-                       }
-
-                       // This will throw exceptions if there's a problem
-                       $this->checkCanExecute( $this->getUser() );
-
-                       $this->onView();
-                       return true;
-               }
-               catch ( ErrorPageError $e ) {
-                       if ( $captureErrors ) {
-                               return false;
-                       } else {
-                               throw $e;
-                       }
-               }
-       }
 }