MediaWiki
master
PatrolLog.php
Go to the documentation of this file.
1
<?php
25
use
MediaWiki\Page\PageReferenceValue
;
26
use
MediaWiki\User\UserIdentity
;
27
32
class
PatrolLog
{
33
45
public
static
function
record
( $rc, $auto,
UserIdentity
$user, $tags =
null
) {
46
// Do not log autopatrol actions: T184485
47
if
( $auto ) {
48
return
false
;
49
}
50
51
if
( !$rc instanceof
RecentChange
) {
52
$rc = RecentChange::newFromId( $rc );
53
if
( !is_object( $rc ) ) {
54
return
false
;
55
}
56
}
57
58
$entry =
new
ManualLogEntry
(
'patrol'
,
'patrol'
);
59
60
// B/C: ->getPage() on RC will return a page reference or null, reconcile this in
61
// $entry->setTarget() call so we don't throw.
62
$page = $rc->getPage() ?? PageReferenceValue::localReference(
NS_SPECIAL
,
'Badtitle'
);
63
$entry->setTarget( $page );
64
$entry->setParameters( self::buildParams( $rc ) );
65
$entry->setPerformer( $user );
66
$entry->addTags( $tags );
67
$logid = $entry->insert();
68
$entry->publish( $logid,
'udp'
);
69
70
return
true
;
71
}
72
79
private
static
function
buildParams( $change ) {
80
return
[
81
'4::curid'
=> $change->getAttribute(
'rc_this_oldid'
),
82
'5::previd'
=> $change->getAttribute(
'rc_last_oldid'
),
83
'6::auto'
=> 0
84
];
85
}
86
}
NS_SPECIAL
const NS_SPECIAL
Definition
Defines.php:54
ManualLogEntry
Class for creating new log entries and inserting them into the database.
Definition
ManualLogEntry.php:49
MediaWiki\Page\PageReferenceValue
Immutable value object representing a page reference.
Definition
PageReferenceValue.php:43
PatrolLog
Class containing static functions for working with logs of patrol events.
Definition
PatrolLog.php:32
PatrolLog\record
static record( $rc, $auto, UserIdentity $user, $tags=null)
Record a log event for a change being patrolled.
Definition
PatrolLog.php:45
RecentChange
Utility class for creating and reading rows in the recentchanges table.
Definition
RecentChange.php:110
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition
UserIdentity.php:39
includes
logging
PatrolLog.php
Generated on Mon Dec 2 2024 10:24:42 for MediaWiki by
1.10.0