r97603 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97602‎ | r97603 | r97604 >
Date:08:39, 20 September 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Moved PatrolLog to logging folder, sorted the autoloaded entries alphabetically
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/PatrolLog.php (deleted) (history)
  • /trunk/phase3/includes/logging/PatrolLog.php (added) (history)

Diff [purge]

Index: trunk/phase3/includes/PatrolLog.php
@@ -1,58 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Class containing static functions for working with
6 - * logs of patrol events
7 - *
8 - * @author Rob Church <robchur@gmail.com>
9 - * @author Niklas Laxström
10 - */
11 -class PatrolLog {
12 -
13 - /**
14 - * Record a log event for a change being patrolled
15 - *
16 - * @param $rc Mixed: change identifier or RecentChange object
17 - * @param $auto Boolean: was this patrol event automatic?
18 - *
19 - * @return bool
20 - */
21 - public static function record( $rc, $auto = false ) {
22 - if ( !$rc instanceof RecentChange ) {
23 - $rc = RecentChange::newFromId( $rc );
24 - if ( !is_object( $rc ) ) {
25 - return false;
26 - }
27 - }
28 -
29 - $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
30 - if( $title ) {
31 - $entry = new ManualLogEntry( 'patrol', 'patrol' );
32 - $entry->setTarget( $title );
33 - $entry->setParameters( self::buildParams( $rc, $auto ) );
34 - $entry->setPerformer( User::newFromName( $rc->getAttribute( 'rc_user_text' ), false ) );
35 - $logid = $entry->insert();
36 - if ( !$auto ) {
37 - $entry->publish( $logid, 'udp' );
38 - }
39 - return true;
40 - }
41 - return false;
42 - }
43 -
44 - /**
45 - * Prepare log parameters for a patrolled change
46 - *
47 - * @param $change RecentChange to represent
48 - * @param $auto Boolean: whether the patrol event was automatic
49 - * @return Array
50 - */
51 - private static function buildParams( $change, $auto ) {
52 - return array(
53 - '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
54 - '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
55 - '6::auto' => (int)$auto
56 - );
57 - }
58 -
59 -}
Index: trunk/phase3/includes/logging/PatrolLog.php
@@ -0,0 +1,58 @@
 2+<?php
 3+
 4+/**
 5+ * Class containing static functions for working with
 6+ * logs of patrol events
 7+ *
 8+ * @author Rob Church <robchur@gmail.com>
 9+ * @author Niklas Laxström
 10+ */
 11+class PatrolLog {
 12+
 13+ /**
 14+ * Record a log event for a change being patrolled
 15+ *
 16+ * @param $rc Mixed: change identifier or RecentChange object
 17+ * @param $auto Boolean: was this patrol event automatic?
 18+ *
 19+ * @return bool
 20+ */
 21+ public static function record( $rc, $auto = false ) {
 22+ if ( !$rc instanceof RecentChange ) {
 23+ $rc = RecentChange::newFromId( $rc );
 24+ if ( !is_object( $rc ) ) {
 25+ return false;
 26+ }
 27+ }
 28+
 29+ $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
 30+ if( $title ) {
 31+ $entry = new ManualLogEntry( 'patrol', 'patrol' );
 32+ $entry->setTarget( $title );
 33+ $entry->setParameters( self::buildParams( $rc, $auto ) );
 34+ $entry->setPerformer( User::newFromName( $rc->getAttribute( 'rc_user_text' ), false ) );
 35+ $logid = $entry->insert();
 36+ if ( !$auto ) {
 37+ $entry->publish( $logid, 'udp' );
 38+ }
 39+ return true;
 40+ }
 41+ return false;
 42+ }
 43+
 44+ /**
 45+ * Prepare log parameters for a patrolled change
 46+ *
 47+ * @param $change RecentChange to represent
 48+ * @param $auto Boolean: whether the patrol event was automatic
 49+ * @return Array
 50+ */
 51+ private static function buildParams( $change, $auto ) {
 52+ return array(
 53+ '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
 54+ '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
 55+ '6::auto' => (int)$auto
 56+ );
 57+ }
 58+
 59+}
Property changes on: trunk/phase3/includes/logging/PatrolLog.php
___________________________________________________________________
Added: svn:eol-style
160 + native
Index: trunk/phase3/includes/AutoLoader.php
@@ -164,7 +164,6 @@
165165 'PageQueryPage' => 'includes/PageQueryPage.php',
166166 'Pager' => 'includes/Pager.php',
167167 'PasswordError' => 'includes/User.php',
168 - 'PatrolLog' => 'includes/PatrolLog.php',
169168 'PermissionsError' => 'includes/Exception.php',
170169 'PhpHttpRequest' => 'includes/HttpFunctions.php',
171170 'PoolCounter' => 'includes/PoolCounter.php',
@@ -538,16 +537,17 @@
539538 'JSParser' => 'includes/libs/jsminplus.php',
540539
541540 # includes/logging
 541+ 'DatabaseLogEntry' => 'includes/logging/LogEntry.php',
 542+ 'DeleteLogFormatter' => 'includes/logging/LogFormatter.php',
 543+ 'LegacyLogFormatter' => 'includes/logging/LogFormatter.php',
542544 'LogEntry' => 'includes/logging/LogEntry.php',
543545 'LogEntryBase' => 'includes/logging/LogEntry.php',
544 - 'DatabaseLogEntry' => 'includes/logging/LogEntry.php',
545 - 'RCDatabaseLogEntry' => 'includes/logging/LogEntry.php',
 546+ 'LogFormatter' => 'includes/logging/LogFormatter.php',
546547 'ManualLogEntry' => 'includes/logging/LogEntry.php',
547 - 'LogFormatter' => 'includes/logging/LogFormatter.php',
548 - 'LegacyLogFormatter' => 'includes/logging/LogFormatter.php',
549 - 'DeleteLogFormatter' => 'includes/logging/LogFormatter.php',
550548 'MoveLogFormatter' => 'includes/logging/LogFormatter.php',
 549+ 'PatrolLog' => 'includes/logging/PatrolLog.php',
551550 'PatrolLogFormatter' => 'includes/logging/LogFormatter.php',
 551+ 'RCDatabaseLogEntry' => 'includes/logging/LogEntry.php',
552552
553553 # includes/media
554554 'BitmapHandler' => 'includes/media/Bitmap.php',

Status & tagging log