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