MediaWiki REL1_28
PatrolLog.php
Go to the documentation of this file.
1<?php
29class PatrolLog {
41 public static function record( $rc, $auto = false, User $user = null, $tags = null ) {
43
44 // do not log autopatrolled edits if setting disables it
45 if ( $auto && !$wgLogAutopatrol ) {
46 return false;
47 }
48
49 if ( !$rc instanceof RecentChange ) {
50 $rc = RecentChange::newFromId( $rc );
51 if ( !is_object( $rc ) ) {
52 return false;
53 }
54 }
55
56 if ( !$user ) {
58 $user = $wgUser;
59 }
60
61 $action = $auto ? 'autopatrol' : 'patrol';
62
63 $entry = new ManualLogEntry( 'patrol', $action );
64 $entry->setTarget( $rc->getTitle() );
65 $entry->setParameters( self::buildParams( $rc, $auto ) );
66 $entry->setPerformer( $user );
67 $entry->setTags( $tags );
68 $logid = $entry->insert();
69 if ( !$auto ) {
70 $entry->publish( $logid, 'udp' );
71 }
72
73 return true;
74 }
75
83 private static function buildParams( $change, $auto ) {
84 return [
85 '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
86 '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
87 '6::auto' => (int)$auto
88 ];
89 }
90}
$wgLogAutopatrol
Log autopatrol actions to the log table.
$wgUser
Definition Setup.php:806
Class for creating log entries manually, to inject them into the database.
Definition LogEntry.php:394
Class containing static functions for working with logs of patrol events.
Definition PatrolLog.php:29
static buildParams( $change, $auto)
Prepare log parameters for a patrolled change.
Definition PatrolLog.php:83
static record( $rc, $auto=false, User $user=null, $tags=null)
Record a log event for a change being patrolled.
Definition PatrolLog.php:41
Utility class for creating new RC entries.
static newFromId( $rcid)
Obtain the recent change with a given rc_id value.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:48
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:249
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped true if there is text before this autocomment $auto
Definition hooks.txt:1554
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37