X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiMove.php;h=2fbd50e2e5a1e69a7e8f7f2400c0df028a3660e9;hb=507643bafe9b09ac3500cb1de617136110cdf55d;hp=aca4378437d95587e21a9704ef7e42f14542caee;hpb=3064c32d822dbd05306ae2b531159b2a68e81e80;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index aca4378437..2fbd50e2e5 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -41,12 +41,12 @@ class ApiMove extends ApiBase { if ( isset( $params['from'] ) ) { $fromTitle = Title::newFromText( $params['from'] ); if ( !$fromTitle || $fromTitle->isExternal() ) { - $this->dieUsageMsg( array( 'invalidtitle', $params['from'] ) ); + $this->dieUsageMsg( [ 'invalidtitle', $params['from'] ] ); } } elseif ( isset( $params['fromid'] ) ) { $fromTitle = Title::newFromID( $params['fromid'] ); if ( !$fromTitle ) { - $this->dieUsageMsg( array( 'nosuchpageid', $params['fromid'] ) ); + $this->dieUsageMsg( [ 'nosuchpageid', $params['fromid'] ] ); } } @@ -57,7 +57,7 @@ class ApiMove extends ApiBase { $toTitle = Title::newFromText( $params['to'] ); if ( !$toTitle || $toTitle->isExternal() ) { - $this->dieUsageMsg( array( 'invalidtitle', $params['to'] ) ); + $this->dieUsageMsg( [ 'invalidtitle', $params['to'] ] ); } $toTalk = $toTitle->getTalkPage(); @@ -79,13 +79,13 @@ class ApiMove extends ApiBase { $this->dieStatus( $status ); } - $r = array( + $r = [ 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] - ); + ]; - //NOTE: we assume that if the old title exists, it's because it was re-created as + // NOTE: we assume that if the old title exists, it's because it was re-created as // a redirect to the new title. This is not safe, but what we did before was // even worse: we just determined whether a redirect should have been created, // and reported that it was created if it should have, without any checks. @@ -130,10 +130,8 @@ class ApiMove extends ApiBase { $watch = $params['watchlist']; } elseif ( $params['watch'] ) { $watch = 'watch'; - $this->logFeatureUsage( 'action=move&watch' ); } elseif ( $params['unwatch'] ) { $watch = 'unwatch'; - $this->logFeatureUsage( 'action=move&unwatch' ); } // Watch pages @@ -178,16 +176,16 @@ class ApiMove extends ApiBase { * @return array */ public function moveSubpages( $fromTitle, $toTitle, $reason, $noredirect ) { - $retval = array(); + $retval = []; $success = $fromTitle->moveSubpages( $toTitle, true, $reason, !$noredirect ); if ( isset( $success[0] ) ) { - return array( 'error' => $this->parseMsg( $success ) ); + return [ 'error' => $this->parseMsg( $success ) ]; } // At least some pages could be moved // Report each of them separately foreach ( $success as $oldTitle => $newTitle ) { - $r = array( 'from' => $oldTitle ); + $r = [ 'from' => $oldTitle ]; if ( is_array( $newTitle ) ) { $r['error'] = $this->parseMsg( reset( $newTitle ) ); } else { @@ -209,38 +207,38 @@ class ApiMove extends ApiBase { } public function getAllowedParams() { - return array( + return [ 'from' => null, - 'fromid' => array( + 'fromid' => [ ApiBase::PARAM_TYPE => 'integer' - ), - 'to' => array( + ], + 'to' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true - ), + ], 'reason' => '', 'movetalk' => false, 'movesubpages' => false, 'noredirect' => false, - 'watch' => array( + 'watch' => [ ApiBase::PARAM_DFLT => false, ApiBase::PARAM_DEPRECATED => true, - ), - 'unwatch' => array( + ], + 'unwatch' => [ ApiBase::PARAM_DFLT => false, ApiBase::PARAM_DEPRECATED => true, - ), - 'watchlist' => array( + ], + 'watchlist' => [ ApiBase::PARAM_DFLT => 'preferences', - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_TYPE => [ 'watch', 'unwatch', 'preferences', 'nochange' - ), - ), + ], + ], 'ignorewarnings' => false - ); + ]; } public function needsToken() { @@ -248,11 +246,11 @@ class ApiMove extends ApiBase { } protected function getExamplesMessages() { - return array( + return [ 'action=move&from=Badtitle&to=Goodtitle&token=123ABC&' . 'reason=Misspelled%20title&movetalk=&noredirect=' => 'apihelp-move-example-move', - ); + ]; } public function getHelpUrls() {