42 private $blockPermissionChecker;
97 $this->blockPermissionChecker = $blockPermissionCheckerFactory
102 $this->blockStore = $blockStore;
103 $this->blockUtils = $blockUtils;
104 $this->userFactory = $userFactory;
105 $this->hookRunner =
new HookRunner( $hookContainer );
108 [ $this->target, $this->targetType ] = $this->blockUtils->parseBlockTarget( $target );
111 is_numeric( $this->target )
114 $this->target =
'#' . $this->target;
117 $this->performer = $performer;
118 $this->reason = $reason;
128 $status =
Status::newGood();
130 $basePermissionCheckResult = $this->blockPermissionChecker->checkBasePermissions(
133 if ( $basePermissionCheckResult !==
true ) {
134 return $status->
fatal( $basePermissionCheckResult );
137 $blockPermissionCheckResult = $this->blockPermissionChecker->checkBlockPermissions();
138 if ( $blockPermissionCheckResult !==
true ) {
139 return $status->fatal( $blockPermissionCheckResult );
142 if ( count( $this->tags ) !== 0 ) {
151 if ( !$status->isOK() ) {
164 $status =
Status::newGood();
166 if ( $this->block ===
null ) {
167 return $status->
fatal(
'ipb_cant_unblock', $this->target );
174 return $status->fatal(
'ipb_blocked_as_range', $this->target, $this->block->getTargetName() );
177 $denyReason = [
'hookaborted' ];
178 $legacyUser = $this->userFactory->newFromAuthority( $this->performer );
179 if ( !$this->hookRunner->onUnblockUser( $this->block, $legacyUser, $denyReason ) ) {
180 foreach ( $denyReason as $key ) {
181 $status->fatal( $key );
186 $deleteBlockStatus = $this->blockStore->deleteBlock( $this->block );
187 if ( !$deleteBlockStatus ) {
188 return $status->fatal(
'ipb_cant_unblock', $this->block->getTargetName() );
191 $this->hookRunner->onUnblockUserComplete( $this->block, $legacyUser );
194 $user = $this->block->getTargetUserIdentity();
195 if ( $this->block->getHideName() && $user ) {
196 $id = $user->getId();
202 $status->setResult( $status->isOK(), $this->block );
209 private function log() {
211 if ( $this->block->getType() === DatabaseBlock::TYPE_AUTO ) {
219 if ( $page !==
null ) {
220 $logEntry->setTarget( $page );
222 $logEntry->setComment( $this->reason );
223 $logEntry->setPerformer( $this->performer->getUser() );
224 $logEntry->addTags( $this->tags );
225 $logEntry->setRelations( [
'ipb_id' => $this->block->getId() ] );
226 $logId = $logEntry->insert();
227 $logEntry->publish( $logId );
Class for creating new log entries and inserting them into the database.
Backend functions for suppressing and unsuppressing all references to a given user,...
static unsuppressUserName( $name, $userId, IDatabase $dbw=null)
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Represents a page (or page fragment) title within MediaWiki.
static tryNew( $namespace, $title, $fragment='', $interwiki='')
Constructs a TitleValue, or returns null if the parameters are not valid.