88 $this->blockPermissionChecker = $blockPermissionCheckerFactory
93 $this->blockStore = $blockStore;
94 $this->blockUtils = $blockUtils;
95 $this->userFactory = $userFactory;
96 $this->hookRunner =
new HookRunner( $hookContainer );
99 [ $this->target, $this->targetType ] = $this->blockUtils->parseBlockTarget( $target );
102 is_numeric( $this->target )
105 $this->target =
'#' . $this->target;
107 $this->block = $this->blockStore->newFromTarget( $this->target );
108 $this->performer = $performer;
109 $this->reason = $reason;
119 $status =
Status::newGood();
121 $basePermissionCheckResult = $this->blockPermissionChecker->checkBasePermissions(
124 if ( $basePermissionCheckResult !==
true ) {
125 return $status->
fatal( $basePermissionCheckResult );
128 $blockPermissionCheckResult = $this->blockPermissionChecker->checkBlockPermissions();
129 if ( $blockPermissionCheckResult !==
true ) {
130 return $status->fatal( $blockPermissionCheckResult );
133 if ( count( $this->tags ) !== 0 ) {
142 if ( !$status->isOK() ) {
155 $status =
Status::newGood();
157 if ( $this->block ===
null ) {
158 return $status->
fatal(
'ipb_cant_unblock', $this->target );
165 return $status->fatal(
'ipb_blocked_as_range', $this->target, $this->block->getTargetName() );
168 $denyReason = [
'hookaborted' ];
169 $legacyUser = $this->userFactory->newFromAuthority( $this->performer );
170 if ( !$this->hookRunner->onUnblockUser( $this->block, $legacyUser, $denyReason ) ) {
171 foreach ( $denyReason as $key ) {
172 $status->fatal( $key );
177 $deleteBlockStatus = $this->blockStore->deleteBlock( $this->block );
178 if ( !$deleteBlockStatus ) {
179 return $status->fatal(
'ipb_cant_unblock', $this->block->getTargetName() );
182 $this->hookRunner->onUnblockUserComplete( $this->block, $legacyUser );
185 $user = $this->block->getTargetUserIdentity();
186 if ( $this->block->getHideName() && $user ) {
187 $id = $user->getId();
193 $status->setResult( $status->isOK(), $this->block );
200 private function log() {
202 if ( $this->block->getType() === DatabaseBlock::TYPE_AUTO ) {
203 $page = TitleValue::tryNew(
NS_USER,
'#' . $this->block->getId() );
205 $page = TitleValue::tryNew(
NS_USER, $this->block->getTargetName() );
210 if ( $page !==
null ) {
211 $logEntry->setTarget( $page );
213 $logEntry->setComment( $this->reason );
214 $logEntry->setPerformer( $this->performer->getUser() );
215 $logEntry->addTags( $this->tags );
216 $logEntry->setRelations( [
'ipb_id' => $this->block->getId() ] );
217 $logId = $logEntry->insert();
218 $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.