From: withoutaname Date: Tue, 15 Jul 2014 18:53:50 +0000 (-0700) Subject: Remove execute() from Action and subclasses X-Git-Tag: 1.31.0-rc.0~14919 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=a4aaac4f80f56c5ed881be423bae96615b4d2249;p=lhc%2Fweb%2Fwiklou.git Remove execute() from Action and subclasses Since show() is always the preferred entry point, this is never used nor implemented properly. Change-Id: I5fde4bbd420a6695b01fb9220542fd3b49060675 --- diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index dc946e42d1..f9280fce9f 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -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 diff --git a/includes/actions/Action.php b/includes/actions/Action.php index d4b08b2e70..839d0edb94 100644 --- a/includes/actions/Action.php +++ b/includes/actions/Action.php @@ -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(); } diff --git a/includes/actions/FormAction.php b/includes/actions/FormAction.php index 7477d11298..c6fcdde0c6 100644 --- a/includes/actions/FormAction.php +++ b/includes/actions/FormAction.php @@ -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; - } - } - } } diff --git a/includes/actions/FormlessAction.php b/includes/actions/FormlessAction.php index 7b3a714ce2..f61fc97d3e 100644 --- a/includes/actions/FormlessAction.php +++ b/includes/actions/FormlessAction.php @@ -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; - } - } - } }