Merge "Revert "Log the reason why revision->getContent() returns null""
[lhc/web/wiklou.git] / includes / revisiondelete / RevDelLogList.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup RevisionDelete
20 */
21
22 use Wikimedia\Rdbms\IDatabase;
23
24 /**
25 * List for logging table items
26 */
27 class RevDelLogList extends RevDelList {
28 public function getType() {
29 return 'logging';
30 }
31
32 public static function getRelationType() {
33 return 'log_id';
34 }
35
36 public static function getRestriction() {
37 return 'deletelogentry';
38 }
39
40 public static function getRevdelConstant() {
41 return LogPage::DELETED_ACTION;
42 }
43
44 public static function suggestTarget( $target, array $ids ) {
45 $result = wfGetDB( DB_REPLICA )->select( 'logging',
46 'log_type',
47 [ 'log_id' => $ids ],
48 __METHOD__,
49 [ 'DISTINCT' ]
50 );
51 if ( $result->numRows() == 1 ) {
52 // If there's only one type, the target can be set to include it.
53 return SpecialPage::getTitleFor( 'Log', $result->current()->log_type );
54 }
55
56 return SpecialPage::getTitleFor( 'Log' );
57 }
58
59 /**
60 * @param IDatabase $db
61 * @return mixed
62 */
63 public function doQuery( $db ) {
64 $ids = array_map( 'intval', $this->ids );
65
66 $commentQuery = CommentStore::getStore()->getJoin( 'log_comment' );
67 $actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
68
69 return $db->select(
70 [ 'logging' ] + $commentQuery['tables'] + $actorQuery['tables'],
71 [
72 'log_id',
73 'log_type',
74 'log_action',
75 'log_timestamp',
76 'log_namespace',
77 'log_title',
78 'log_page',
79 'log_params',
80 'log_deleted'
81 ] + $commentQuery['fields'] + $actorQuery['fields'],
82 [ 'log_id' => $ids ],
83 __METHOD__,
84 [ 'ORDER BY' => 'log_id DESC' ],
85 $commentQuery['joins'] + $actorQuery['joins']
86 );
87 }
88
89 public function newItem( $row ) {
90 return new RevDelLogItem( $this, $row );
91 }
92
93 public function getSuppressBit() {
94 return Revision::DELETED_RESTRICTED;
95 }
96
97 public function getLogAction() {
98 return 'event';
99 }
100
101 public function getLogParams( $params ) {
102 return [
103 '4::ids' => $params['ids'],
104 '5::ofield' => $params['oldBits'],
105 '6::nfield' => $params['newBits'],
106 ];
107 }
108 }