74 $this->blockStore = $blockStore;
75 $this->blockTargetFactory = $blockTargetFactory;
76 $this->userFactory = $userFactory;
77 $this->hookRunner =
new HookRunner( $hookContainer );
80 if ( $blockToRemove !==
null ) {
81 $this->blockToRemove = $blockToRemove;
82 $this->target = $blockToRemove->
getTarget();
84 $this->target = $target;
87 $this->target = $this->blockTargetFactory->newFromLegacyUnion( $target );
90 $this->blockPermissionChecker = $blockPermissionCheckerFactory
95 $this->performer = $performer;
96 $this->reason = $reason;
104 $status =
Status::newGood();
106 $this->block = $this->getBlockToRemove( $status );
107 if ( !$status->isOK() ) {
111 $blockPermissionCheckResult = $this->blockPermissionChecker->checkBlockPermissions( $this->target );
112 if ( $blockPermissionCheckResult !==
true ) {
113 return $status->fatal( $blockPermissionCheckResult );
116 $basePermissionCheckResult = $this->blockPermissionChecker->checkBasePermissions(
117 $this->block instanceof DatabaseBlock && $this->block->getHideName()
120 if ( $basePermissionCheckResult !==
true ) {
121 return $status->fatal( $basePermissionCheckResult );
124 if ( count( $this->tags ) !== 0 ) {
126 ChangeTags::canAddTagsAccompanyingChange(
133 if ( !$status->isOK() ) {
147 $status =
Status::newGood();
149 $this->block ??= $this->getBlockToRemove( $status );
150 if ( !$status->isOK() ) {
154 if ( $this->block ===
null ) {
155 return $status->fatal(
'ipb_cant_unblock', $this->target->toString() );
162 return $status->fatal(
'ipb_blocked_as_range', $this->target->toString(), $this->block->getTargetName() );
165 $denyReason = [
'hookaborted' ];
166 $legacyUser = $this->userFactory->newFromAuthority( $this->performer );
167 if ( !$this->hookRunner->onUnblockUser( $this->block, $legacyUser, $denyReason ) ) {
168 foreach ( $denyReason as $key ) {
169 $status->fatal( $key );
174 $deleteBlockStatus = $this->blockStore->deleteBlock( $this->block );
175 if ( !$deleteBlockStatus ) {
176 return $status->fatal(
'ipb_cant_unblock', $this->block->getTargetName() );
179 $this->hookRunner->onUnblockUserComplete( $this->block, $legacyUser );
182 $user = $this->block->getTargetUserIdentity();
183 if ( $this->block->getHideName() && $user ) {
184 $id = $user->getId();
185 RevisionDeleteUser::unsuppressUserName( $user->getName(), $id );
190 $status->setResult( $status->isOK(), $this->block );