MediaWiki  REL1_31
Go to the documentation of this file.
1 <?php
29 class PatrolLog {
42  public static function record( $rc, $auto = false, User $user = null, $tags = null ) {
43  // Do not log autopatrol actions: T184485
44  if ( $auto ) {
45  return false;
46  }
48  if ( !$rc instanceof RecentChange ) {
49  $rc = RecentChange::newFromId( $rc );
50  if ( !is_object( $rc ) ) {
51  return false;
52  }
53  }
55  if ( !$user ) {
57  $user = $wgUser;
58  }
60  $action = $auto ? 'autopatrol' : 'patrol';
62  $entry = new ManualLogEntry( 'patrol', $action );
63  $entry->setTarget( $rc->getTitle() );
64  $entry->setParameters( self::buildParams( $rc, $auto ) );
65  $entry->setPerformer( $user );
66  $entry->setTags( $tags );
67  $logid = $entry->insert();
68  if ( !$auto ) {
69  $entry->publish( $logid, 'udp' );
70  }
72  return true;
73  }
82  private static function buildParams( $change, $auto ) {
83  return [
84  '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
85  '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
86  '6::auto' => (int)$auto
87  ];
88  }
89 }
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 account $user
Definition: hooks.txt:247
Definition: Setup.php:902
static record( $rc, $auto=false, User $user=null, $tags=null)
Record a log event for a change being patrolled.
Definition: PatrolLog.php:42
Utility class for creating new RC entries.
Definition: RecentChange.php:68
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
static buildParams( $change, $auto)
Prepare log parameters for a patrolled change.
Definition: PatrolLog.php:82
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
static newFromId( $rcid)
Obtain the recent change with a given rc_id value.
Definition: RecentChange.php:181
Class containing static functions for working with logs of patrol events.
Definition: PatrolLog.php:29
Class for creating log entries manually, to inject them into the database.
Definition: LogEntry.php:432
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:53
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 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:1587