Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 57 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
| RevDelLogList | |
0.00% |
0 / 56 |
|
0.00% |
0 / 10 |
132 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRelationType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRestriction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRevdelConstant | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| suggestTarget | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |||
| doQuery | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
2 | |||
| newItem | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| getLogAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLogParams | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | * @ingroup RevisionDelete |
| 6 | */ |
| 7 | |
| 8 | namespace MediaWiki\RevisionDelete; |
| 9 | |
| 10 | use MediaWiki\CommentStore\CommentStore; |
| 11 | use MediaWiki\Context\IContextSource; |
| 12 | use MediaWiki\Logging\LogFormatterFactory; |
| 13 | use MediaWiki\Logging\LogPage; |
| 14 | use MediaWiki\MediaWikiServices; |
| 15 | use MediaWiki\Page\PageIdentity; |
| 16 | use MediaWiki\SpecialPage\SpecialPage; |
| 17 | use Wikimedia\Rdbms\IResultWrapper; |
| 18 | use Wikimedia\Rdbms\LBFactory; |
| 19 | use Wikimedia\Rdbms\SelectQueryBuilder; |
| 20 | |
| 21 | /** |
| 22 | * List for logging table items |
| 23 | */ |
| 24 | class RevDelLogList extends RevDelList { |
| 25 | |
| 26 | protected const SUPPRESS_BIT = LogPage::DELETED_RESTRICTED; |
| 27 | |
| 28 | /** @var CommentStore */ |
| 29 | private $commentStore; |
| 30 | private LogFormatterFactory $logFormatterFactory; |
| 31 | |
| 32 | /** |
| 33 | * @internal Use RevisionDeleter |
| 34 | * @param IContextSource $context |
| 35 | * @param PageIdentity $page |
| 36 | * @param array $ids |
| 37 | * @param LBFactory $lbFactory |
| 38 | * @param CommentStore $commentStore |
| 39 | * @param LogFormatterFactory $logFormatterFactory |
| 40 | */ |
| 41 | public function __construct( |
| 42 | IContextSource $context, |
| 43 | PageIdentity $page, |
| 44 | array $ids, |
| 45 | LBFactory $lbFactory, |
| 46 | CommentStore $commentStore, |
| 47 | LogFormatterFactory $logFormatterFactory |
| 48 | ) { |
| 49 | parent::__construct( $context, $page, $ids, $lbFactory ); |
| 50 | $this->commentStore = $commentStore; |
| 51 | $this->logFormatterFactory = $logFormatterFactory; |
| 52 | } |
| 53 | |
| 54 | /** @inheritDoc */ |
| 55 | public function getType() { |
| 56 | return 'logging'; |
| 57 | } |
| 58 | |
| 59 | /** @inheritDoc */ |
| 60 | public static function getRelationType() { |
| 61 | return 'log_id'; |
| 62 | } |
| 63 | |
| 64 | /** @inheritDoc */ |
| 65 | public static function getRestriction() { |
| 66 | return 'deletelogentry'; |
| 67 | } |
| 68 | |
| 69 | /** @inheritDoc */ |
| 70 | public static function getRevdelConstant() { |
| 71 | return LogPage::DELETED_ACTION; |
| 72 | } |
| 73 | |
| 74 | /** @inheritDoc */ |
| 75 | public static function suggestTarget( $target, array $ids ) { |
| 76 | $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase(); |
| 77 | $result = $dbr->newSelectQueryBuilder() |
| 78 | ->select( 'log_type' ) |
| 79 | ->distinct() |
| 80 | ->from( 'logging' ) |
| 81 | ->where( [ 'log_id' => $ids ] ) |
| 82 | ->caller( __METHOD__ )->fetchResultSet(); |
| 83 | if ( $result->numRows() == 1 ) { |
| 84 | // If there's only one type, the target can be set to include it. |
| 85 | return SpecialPage::getTitleFor( 'Log', $result->current()->log_type ); |
| 86 | } |
| 87 | |
| 88 | return SpecialPage::getTitleFor( 'Log' ); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @param \Wikimedia\Rdbms\IReadableDatabase $db |
| 93 | * @return IResultWrapper |
| 94 | */ |
| 95 | public function doQuery( $db ) { |
| 96 | $ids = array_map( 'intval', $this->ids ); |
| 97 | $queryBuilder = $db->newSelectQueryBuilder() |
| 98 | ->select( [ |
| 99 | 'log_id', |
| 100 | 'log_type', |
| 101 | 'log_action', |
| 102 | 'log_timestamp', |
| 103 | 'log_actor', |
| 104 | 'log_namespace', |
| 105 | 'log_title', |
| 106 | 'log_page', |
| 107 | 'log_params', |
| 108 | 'log_deleted', |
| 109 | 'log_user' => 'actor_user', |
| 110 | 'log_user_text' => 'actor_name', |
| 111 | 'log_comment_text' => 'comment_log_comment.comment_text', |
| 112 | 'log_comment_data' => 'comment_log_comment.comment_data', |
| 113 | 'log_comment_cid' => 'comment_log_comment.comment_id' |
| 114 | ] ) |
| 115 | ->from( 'logging' ) |
| 116 | ->join( 'actor', null, 'actor_id=log_actor' ) |
| 117 | ->join( 'comment', 'comment_log_comment', 'comment_log_comment.comment_id = log_comment_id' ) |
| 118 | ->where( [ 'log_id' => $ids ] ) |
| 119 | ->orderBy( [ 'log_timestamp', 'log_id' ], SelectQueryBuilder::SORT_DESC ); |
| 120 | |
| 121 | MediaWikiServices::getInstance()->getChangeTagsStore()->modifyDisplayQueryBuilder( $queryBuilder, 'logging' ); |
| 122 | |
| 123 | return $queryBuilder->caller( __METHOD__ )->fetchResultSet(); |
| 124 | } |
| 125 | |
| 126 | /** @inheritDoc */ |
| 127 | public function newItem( $row ) { |
| 128 | return new RevDelLogItem( |
| 129 | $this, |
| 130 | $row, |
| 131 | $this->commentStore, |
| 132 | MediaWikiServices::getInstance()->getConnectionProvider(), |
| 133 | $this->logFormatterFactory |
| 134 | ); |
| 135 | } |
| 136 | |
| 137 | /** @inheritDoc */ |
| 138 | public function getLogAction() { |
| 139 | return 'event'; |
| 140 | } |
| 141 | |
| 142 | /** @inheritDoc */ |
| 143 | public function getLogParams( $params ) { |
| 144 | return [ |
| 145 | '4::ids' => $params['ids'], |
| 146 | '5::ofield' => $params['oldBits'], |
| 147 | '6::nfield' => $params['newBits'], |
| 148 | ]; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | /** @deprecated class alias since 1.46 */ |
| 153 | class_alias( RevDelLogList::class, 'RevDelLogList' ); |