);
}
+ /**
+ * Throw a UsageException, which will (if uncaught) call the main module's
+ * error handler and die with an error message including block info.
+ *
+ * @since 1.27
+ * @param Block $block The block used to generate the UsageException
+ * @throws UsageException always
+ */
+ public function dieBlocked( Block $block ) {
+ // Die using the appropriate message depending on block type
+ if ( $block->getType() == Block::TYPE_AUTO ) {
+ $this->dieUsage(
+ 'Your IP address has been blocked automatically, because it was used by a blocked user',
+ 'autoblocked',
+ 0,
+ array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) )
+ );
+ } else {
+ $this->dieUsage(
+ 'You have been blocked from editing',
+ 'blocked',
+ 0,
+ array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) )
+ );
+ }
+ }
+
/**
* Get error (as code, string) from a Status object.
*
$params = $this->extractRequestParams();
$user = $this->getUser();
-
if ( !$user->isAllowed( RevisionDeleter::getRestriction( $params['type'] ) ) ) {
$this->dieUsageMsg( 'badaccess-group0' );
}
if ( $user->isBlocked() ) {
- $block = $user->getBlock();
-
- // Die using the appropriate message depending on block type
- if ( $block->getType() == TYPE_AUTO ) {
- $this->dieUsage(
- 'Your IP address has been blocked automatically, because it was used by a blocked user',
- 'autoblocked',
- 0,
- array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) )
- );
- } else {
- $this->dieUsage(
- 'You have been blocked from editing',
- 'blocked',
- 0,
- array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) )
- );
- }
+ $this->dieBlocked( $user->getBlock() );
}
if ( !$params['ids'] ) {
}
if ( $user->isBlocked() ) {
- $block = $user->getBlock();
-
- // Die using the appropriate message depending on block type
- if ( $block->getType() == TYPE_AUTO ) {
- $this->dieUsage(
- 'Your IP address has been blocked automatically, because it was used by a blocked user',
- 'autoblocked',
- 0,
- array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) )
- );
- } else {
- $this->dieUsage(
- 'You have been blocked from editing',
- 'blocked',
- 0,
- array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) )
- );
- }
+ $this->dieBlocked( $user->getBlock() );
}
// validate and process each revid, rcid and logid
$this->useTransactionalTimeLimit();
$params = $this->extractRequestParams();
-
- if ( !$this->getUser()->isAllowed( 'undelete' ) ) {
+ $user = $this->getUser();
+ if ( !$user->isAllowed( 'undelete' ) ) {
$this->dieUsageMsg( 'permdenied-undelete' );
}
- if ( $this->getUser()->isBlocked() ) {
- $this->dieUsage(
- 'You have been blocked from editing',
- 'blocked',
- 0,
- array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $this->getUser()->getBlock() ) )
- );
+ if ( $user->isBlocked() ) {
+ $this->dieBlocked( $user->getBlock() );
}
$titleObj = Title::newFromText( $params['title'] );