MediaWiki  master
RevDelLogList.php
Go to the documentation of this file.
1 <?php
29 
33 class RevDelLogList extends RevDelList {
34 
36 
38  private $commentStore;
39 
48  public function __construct(
49  IContextSource $context,
51  array $ids,
52  LBFactory $lbFactory,
53  CommentStore $commentStore
54  ) {
55  parent::__construct( $context, $page, $ids, $lbFactory );
56  $this->commentStore = $commentStore;
57  }
58 
59  public function getType() {
60  return 'logging';
61  }
62 
63  public static function getRelationType() {
64  return 'log_id';
65  }
66 
67  public static function getRestriction() {
68  return 'deletelogentry';
69  }
70 
71  public static function getRevdelConstant() {
73  }
74 
75  public static function suggestTarget( $target, array $ids ) {
76  $dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->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 
95  public function doQuery( $db ) {
96  $ids = array_map( 'intval', $this->ids );
97 
98  $commentQuery = $this->commentStore->getJoin( 'log_comment' );
99 
100  $queryInfo = [
101  'tables' => [ 'logging', 'actor' ] + $commentQuery['tables'],
102  'fields' => [
103  'log_id',
104  'log_type',
105  'log_action',
106  'log_timestamp',
107  'log_actor',
108  'log_namespace',
109  'log_title',
110  'log_page',
111  'log_params',
112  'log_deleted',
113  'log_user' => 'actor_user',
114  'log_user_text' => 'actor_name'
115  ] + $commentQuery['fields'],
116  'conds' => [ 'log_id' => $ids ],
117  'options' => [ 'ORDER BY' => [ 'log_timestamp DESC', 'log_id DESC' ] ],
118  'join_conds' => [
119  'actor' => [ 'JOIN', 'actor_id=log_actor' ]
120  ] + $commentQuery['joins'],
121  ];
122 
124  $queryInfo['tables'],
125  $queryInfo['fields'],
126  $queryInfo['conds'],
127  $queryInfo['join_conds'],
128  $queryInfo['options'],
129  ''
130  );
131 
132  return $db->select(
133  $queryInfo['tables'],
134  $queryInfo['fields'],
135  $queryInfo['conds'],
136  __METHOD__,
137  $queryInfo['options'],
138  $queryInfo['join_conds']
139  );
140  }
141 
142  public function newItem( $row ) {
143  return new RevDelLogItem( $this, $row, $this->commentStore );
144  }
145 
146  public function getLogAction() {
147  return 'event';
148  }
149 
150  public function getLogParams( $params ) {
151  return [
152  '4::ids' => $params['ids'],
153  '5::ofield' => $params['oldBits'],
154  '6::nfield' => $params['newBits'],
155  ];
156  }
157 }
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='', bool $exclude=false)
Applies all tags-related changes to a query.
Definition: ChangeTags.php:631
const DELETED_RESTRICTED
Definition: LogPage.php:47
const DELETED_ACTION
Definition: LogPage.php:44
Handle database storage of comments such as edit summaries and log reasons.
Service locator for MediaWiki core services.
Parent class for all special pages.
Definition: SpecialPage.php:66
Item class for a logging table row.
List for logging table items.
getLogParams( $params)
Get log parameter array.
getLogAction()
Get the log action for this list type.
static getRestriction()
Get the user right required for this list type Override this function.
static getRelationType()
Get the DB field name associated with the ID list.
getType()
Get the internal type name of this list.
static suggestTarget( $target, array $ids)
Suggest a target for the revision deletion Optionally override this function.
static getRevdelConstant()
Get the revision deletion constant for this list type Override this function.
newItem( $row)
Create an item object from a DB result row.
__construct(IContextSource $context, PageIdentity $page, array $ids, LBFactory $lbFactory, CommentStore $commentStore)
PageIdentity $page
Interface for objects which can provide a MediaWiki context on request.
Interface for objects (potentially) representing an editable wiki page.
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:36
Result wrapper for grabbing data queried from an IDatabase object.