Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
94.00% |
47 / 50 |
|
66.67% |
4 / 6 |
CRAP | |
0.00% |
0 / 1 |
| SpecialDeletedContributions | |
95.92% |
47 / 49 |
|
66.67% |
4 / 6 |
10 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
1 | |||
| getPager | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
2 | |||
| isIncludable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUserLinks | |
91.67% |
11 / 12 |
|
0.00% |
0 / 1 |
2.00 | |||
| getResultsPageTitleMessageKey | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| shouldShowIPRangeNavigationLinks | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Specials; |
| 8 | |
| 9 | use MediaWiki\Block\DatabaseBlockStore; |
| 10 | use MediaWiki\CommentFormatter\CommentFormatter; |
| 11 | use MediaWiki\Page\LinkBatchFactory; |
| 12 | use MediaWiki\Pager\DeletedContribsPager; |
| 13 | use MediaWiki\Permissions\PermissionManager; |
| 14 | use MediaWiki\Revision\RevisionStore; |
| 15 | use MediaWiki\SpecialPage\ContributionsSpecialPage; |
| 16 | use MediaWiki\SpecialPage\SpecialPage; |
| 17 | use MediaWiki\Title\NamespaceInfo; |
| 18 | use MediaWiki\User\Options\UserOptionsLookup; |
| 19 | use MediaWiki\User\TempUser\TempUserConfig; |
| 20 | use MediaWiki\User\User; |
| 21 | use MediaWiki\User\UserFactory; |
| 22 | use MediaWiki\User\UserGroupAssignmentService; |
| 23 | use MediaWiki\User\UserIdentity; |
| 24 | use MediaWiki\User\UserIdentityLookup; |
| 25 | use MediaWiki\User\UserNamePrefixSearch; |
| 26 | use MediaWiki\User\UserNameUtils; |
| 27 | use Wikimedia\IPUtils; |
| 28 | use Wikimedia\Rdbms\IConnectionProvider; |
| 29 | |
| 30 | /** |
| 31 | * Implements Special:DeletedContributions to display archived revisions |
| 32 | * |
| 33 | * @ingroup SpecialPage |
| 34 | */ |
| 35 | class SpecialDeletedContributions extends ContributionsSpecialPage { |
| 36 | private ?DeletedContribsPager $pager = null; |
| 37 | |
| 38 | public function __construct( |
| 39 | PermissionManager $permissionManager, |
| 40 | IConnectionProvider $dbProvider, |
| 41 | private readonly RevisionStore $revisionStore, |
| 42 | NamespaceInfo $namespaceInfo, |
| 43 | UserNameUtils $userNameUtils, |
| 44 | UserNamePrefixSearch $userNamePrefixSearch, |
| 45 | UserOptionsLookup $userOptionsLookup, |
| 46 | private readonly CommentFormatter $commentFormatter, |
| 47 | private readonly LinkBatchFactory $linkBatchFactory, |
| 48 | UserFactory $userFactory, |
| 49 | UserIdentityLookup $userIdentityLookup, |
| 50 | DatabaseBlockStore $blockStore, |
| 51 | UserGroupAssignmentService $userGroupAssignmentService, |
| 52 | private readonly TempUserConfig $tempUserConfig |
| 53 | ) { |
| 54 | parent::__construct( |
| 55 | $permissionManager, |
| 56 | $dbProvider, |
| 57 | $namespaceInfo, |
| 58 | $userNameUtils, |
| 59 | $userNamePrefixSearch, |
| 60 | $userOptionsLookup, |
| 61 | $userFactory, |
| 62 | $userIdentityLookup, |
| 63 | $blockStore, |
| 64 | $userGroupAssignmentService, |
| 65 | 'DeletedContributions', |
| 66 | 'deletedhistory' |
| 67 | ); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @inheritDoc |
| 72 | */ |
| 73 | protected function getPager( $targetUser ) { |
| 74 | if ( $this->pager === null ) { |
| 75 | // Fields in the opts property are usually not normalised, mainly |
| 76 | // for validations in HTMLForm, especially the 'target' field. |
| 77 | $options = $this->opts; |
| 78 | unset( $options['target'] ); |
| 79 | |
| 80 | $this->pager = new DeletedContribsPager( |
| 81 | $this->getHookContainer(), |
| 82 | $this->getLinkRenderer(), |
| 83 | $this->dbProvider, |
| 84 | $this->revisionStore, |
| 85 | $this->namespaceInfo, |
| 86 | $this->commentFormatter, |
| 87 | $this->linkBatchFactory, |
| 88 | $this->userFactory, |
| 89 | $this->getContext(), |
| 90 | $options, |
| 91 | $targetUser |
| 92 | ); |
| 93 | } |
| 94 | |
| 95 | return $this->pager; |
| 96 | } |
| 97 | |
| 98 | /** @inheritDoc */ |
| 99 | public function isIncludable() { |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * @inheritDoc |
| 105 | */ |
| 106 | protected function getUserLinks( |
| 107 | SpecialPage $sp, |
| 108 | User $target |
| 109 | ) { |
| 110 | $tools = parent::getUserLinks( $sp, $target ); |
| 111 | $linkRenderer = $sp->getLinkRenderer(); |
| 112 | |
| 113 | $contributionsLink = $linkRenderer->makeKnownLink( |
| 114 | SpecialPage::getTitleFor( 'Contributions', $target->getName() ), |
| 115 | $this->msg( 'sp-deletedcontributions-contribs' )->text() |
| 116 | ); |
| 117 | if ( isset( $tools['deletedcontribs'] ) ) { |
| 118 | // Swap out the deletedcontribs link for our contribs one |
| 119 | $tools = wfArrayInsertAfter( |
| 120 | $tools, [ 'contribs' => $contributionsLink ], 'deletedcontribs' ); |
| 121 | unset( $tools['deletedcontribs'] ); |
| 122 | } else { |
| 123 | $tools['contribs'] = $contributionsLink; |
| 124 | } |
| 125 | |
| 126 | return $tools; |
| 127 | } |
| 128 | |
| 129 | /** @inheritDoc */ |
| 130 | protected function getResultsPageTitleMessageKey( UserIdentity $target ) { |
| 131 | // The following messages are generated here: |
| 132 | // * deletedcontributions-title |
| 133 | // * deletedcontributions-title-for-ip-when-temporary-accounts-enabled |
| 134 | $messageKey = 'deletedcontributions-title'; |
| 135 | if ( $this->tempUserConfig->isEnabled() && IPUtils::isIPAddress( $target->getName() ) ) { |
| 136 | $messageKey .= '-for-ip-when-temporary-accounts-enabled'; |
| 137 | } |
| 138 | return $messageKey; |
| 139 | } |
| 140 | |
| 141 | /** @inheritDoc */ |
| 142 | protected function shouldShowIPRangeNavigationLinks( User $userObj ): bool { |
| 143 | // This page doesn't support IP range lookup, so don't suggest viewing it by range |
| 144 | return false; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | /** @deprecated class alias since 1.41 */ |
| 149 | class_alias( SpecialDeletedContributions::class, 'SpecialDeletedContributions' ); |