Also made the code flow easier to understand by moving
calls to ApiBase::extractRequestParams up in the stack.
Change-Id: I346c6ae4fc0b48c5a794c3d621018baf9bde6b9e
Follows-up: I9c4e4fa
$params = $this->extractRequestParams();
// User and title already validated in call to getTokenSalt from Main
$params = $this->extractRequestParams();
// User and title already validated in call to getTokenSalt from Main
- $titleObj = $this->getRbTitle();
+ $titleObj = $this->getRbTitle( $params );
$pageObj = WikiPage::factory( $titleObj );
$summary = $params['summary'];
$details = array();
$retval = $pageObj->doRollback(
$pageObj = WikiPage::factory( $titleObj );
$summary = $params['summary'];
$details = array();
$retval = $pageObj->doRollback(
+ $this->getRbUser( $params ),
$summary,
$params['token'],
$params['markbot'],
$summary,
$params['token'],
$params['markbot'],
}
public function getTokenSalt() {
}
public function getTokenSalt() {
- return array( $this->getRbTitle()->getPrefixedText(), $this->getRbUser() );
+ $params = $this->extractRequestParams();
+
+ return array(
+ $this->getRbTitle( $params )->getPrefixedText(),
+ $this->getRbUser( $params )
+ );
- private function getRbUser() {
+ /**
+ * @param array $params
+ *
+ * @return string
+ */
+ private function getRbUser( array $params ) {
if ( $this->mUser !== null ) {
return $this->mUser;
}
if ( $this->mUser !== null ) {
return $this->mUser;
}
- $params = $this->extractRequestParams();
-
// We need to be able to revert IPs, but getCanonicalName rejects them
$this->mUser = User::isIP( $params['user'] )
? $params['user']
// We need to be able to revert IPs, but getCanonicalName rejects them
$this->mUser = User::isIP( $params['user'] )
? $params['user']
+ * @param array $params
+ *
- private function getRbTitle() {
+ private function getRbTitle( array $params ) {
if ( $this->mTitleObj !== null ) {
return $this->mTitleObj;
}
if ( $this->mTitleObj !== null ) {
return $this->mTitleObj;
}
- $params = $this->extractRequestParams();
+ $this->requireOnlyOneParameter( $params, 'title', 'pageid' );
if ( isset( $params['title'] ) ) {
$this->mTitleObj = Title::newFromText( $params['title'] );
if ( isset( $params['title'] ) ) {
$this->mTitleObj = Title::newFromText( $params['title'] );