MediaWiki  master
RevDelLogList.php
Go to the documentation of this file.
1 <?php
27 
31 class RevDelLogList extends RevDelList {
32 
34  private $commentStore;
35 
44  public function __construct(
45  IContextSource $context,
47  array $ids,
48  LBFactory $lbFactory,
49  CommentStore $commentStore
50  ) {
51  parent::__construct( $context, $page, $ids, $lbFactory );
52  $this->commentStore = $commentStore;
53  }
54 
55  public function getType() {
56  return 'logging';
57  }
58 
59  public static function getRelationType() {
60  return 'log_id';
61  }
62 
63  public static function getRestriction() {
64  return 'deletelogentry';
65  }
66 
67  public static function getRevdelConstant() {
69  }
70 
71  public static function suggestTarget( $target, array $ids ) {
72  $result = wfGetDB( DB_REPLICA )->select( 'logging',
73  'log_type',
74  [ 'log_id' => $ids ],
75  __METHOD__,
76  [ 'DISTINCT' ]
77  );
78  if ( $result->numRows() == 1 ) {
79  // If there's only one type, the target can be set to include it.
80  return SpecialPage::getTitleFor( 'Log', $result->current()->log_type );
81  }
82 
83  return SpecialPage::getTitleFor( 'Log' );
84  }
85 
90  public function doQuery( $db ) {
91  $ids = array_map( 'intval', $this->ids );
92 
93  $commentQuery = $this->commentStore->getJoin( 'log_comment' );
94 
95  $queryInfo = [
96  'tables' => [ 'logging', 'actor' ] + $commentQuery['tables'],
97  'fields' => [
98  'log_id',
99  'log_type',
100  'log_action',
101  'log_timestamp',
102  'log_actor',
103  'log_namespace',
104  'log_title',
105  'log_page',
106  'log_params',
107  'log_deleted',
108  'log_user' => 'actor_user',
109  'log_user_text' => 'actor_name'
110  ] + $commentQuery['fields'],
111  'conds' => [ 'log_id' => $ids ],
112  'options' => [ 'ORDER BY' => [ 'log_timestamp DESC', 'log_id DESC' ] ],
113  'join_conds' => [
114  'actor' => [ 'JOIN', 'actor_id=log_actor' ]
115  ] + $commentQuery['joins'],
116  ];
117 
119  $queryInfo['tables'],
120  $queryInfo['fields'],
121  $queryInfo['conds'],
122  $queryInfo['join_conds'],
123  $queryInfo['options'],
124  ''
125  );
126 
127  return $db->select(
128  $queryInfo['tables'],
129  $queryInfo['fields'],
130  $queryInfo['conds'],
131  __METHOD__,
132  $queryInfo['options'],
133  $queryInfo['join_conds']
134  );
135  }
136 
137  public function newItem( $row ) {
138  return new RevDelLogItem( $this, $row, $this->commentStore );
139  }
140 
141  public function getSuppressBit() {
142  return RevisionRecord::DELETED_RESTRICTED;
143  }
144 
145  public function getLogAction() {
146  return 'event';
147  }
148 
149  public function getLogParams( $params ) {
150  return [
151  '4::ids' => $params['ids'],
152  '5::ofield' => $params['oldBits'],
153  '6::nfield' => $params['newBits'],
154  ];
155  }
156 }
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='', bool $exclude=false)
Applies all tags-related changes to a query.
Definition: ChangeTags.php:902
const DELETED_ACTION
Definition: LogPage.php:41
Handle database storage of comments such as edit summaries and log reasons.
Page revision base class.
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.
getSuppressBit()
Get the integer value of the flag used for suppression.
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
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
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:40
const DB_REPLICA
Definition: defines.php:26