Index: branches/robchurch/logs/maintenance/tables.sql |
— | — | @@ -848,15 +848,18 @@ |
849 | 849 | -- Visibility of deleted revisions, bitfield |
850 | 850 | rc_deleted tinyint unsigned NOT NULL default '0', |
851 | 851 | |
852 | | - -- Value corresonding to log_id, specific log entries |
853 | | - rc_logid int unsigned NOT NULL default '0', |
854 | | - -- Store log type info here, or null |
855 | | - rc_log_type varbinary(255) NULL default NULL, |
856 | | - -- Store log action or null |
857 | | - rc_log_action varbinary(255) NULL default NULL, |
858 | | - -- Log params |
| 852 | + -- These columns store additional data used for formatting |
| 853 | + |
| 854 | + -- when the change represents a log item |
| 855 | + -- `logging`.`log_id` value |
| 856 | + rc_logid INT UNSIGNED NOT NULL DEFAULT '0', |
| 857 | + -- `logging`.`log_type` value |
| 858 | + rc_log_type VARBINARY(255) NULL, |
| 859 | + -- `logging`.`log_action` value |
| 860 | + rc_log_action VARBINARY(255) NULL, |
| 861 | + -- `logging`.`log_params` value |
859 | 862 | rc_params BLOB NULL, |
860 | | - |
| 863 | + |
861 | 864 | PRIMARY KEY rc_id (rc_id), |
862 | 865 | INDEX rc_timestamp (rc_timestamp), |
863 | 866 | INDEX rc_namespace_title (rc_namespace, rc_title), |
Index: branches/robchurch/logs/includes/RecentChange.php |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | * rc_patrolled boolean whether or not someone has marked this edit as patrolled |
27 | 27 | * rc_old_len integer byte length of the text before the edit |
28 | 28 | * rc_new_len the same after the edit |
| 29 | + * rc_params |
29 | 30 | * |
30 | 31 | * mExtra: |
31 | 32 | * prefixedDBkey prefixed db key, used by external app via msg queue |
— | — | @@ -379,27 +380,33 @@ |
380 | 381 | RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, true ); |
381 | 382 | } |
382 | 383 | |
383 | | - # A log entry is different to an edit in that previous revisions are |
384 | | - # not kept |
385 | | - /*static*/ function notifyLog( $timestamp, &$title, &$user, $comment, $ip='', |
386 | | - $type, $action, $target, $logComment, $params ) |
387 | | - { |
388 | | - if ( !$ip ) { |
| 384 | + /** |
| 385 | + * Insert a change corresponding to a log item |
| 386 | + * |
| 387 | + * @param string $timestamp |
| 388 | + * @param Title $target |
| 389 | + * @param User $user |
| 390 | + * @param string $comment |
| 391 | + * @param string $ip |
| 392 | + * @param string $type |
| 393 | + * @param string $action |
| 394 | + * @param string $comment |
| 395 | + * @param string $params |
| 396 | + */ |
| 397 | + public static function notifyLog( $timestamp, $target, $user, $comment, $ip, $type, $action, $params ) { |
| 398 | + if( !$ip ) |
389 | 399 | $ip = wfGetIP(); |
390 | | - if ( !$ip ) { |
391 | | - $ip = ''; |
392 | | - } |
393 | | - } |
394 | | - |
395 | | - $rc = new RecentChange; |
| 400 | + if( !$ip ) |
| 401 | + $ip = ''; |
| 402 | + $rc = new RecentChange(); |
396 | 403 | $rc->mAttribs = array( |
397 | 404 | 'rc_timestamp' => $timestamp, |
398 | 405 | 'rc_cur_time' => $timestamp, |
399 | | - 'rc_namespace' => $title->getNamespace(), |
400 | | - 'rc_title' => $title->getDBkey(), |
| 406 | + 'rc_namespace' => $target->getNamespace(), |
| 407 | + 'rc_title' => $target->getDBkey(), |
401 | 408 | 'rc_type' => RC_LOG, |
402 | 409 | 'rc_minor' => 0, |
403 | | - 'rc_cur_id' => $title->getArticleID(), |
| 410 | + 'rc_cur_id' => $target->getArticleID(), |
404 | 411 | 'rc_user' => $user->getID(), |
405 | 412 | 'rc_user_text' => $user->getName(), |
406 | 413 | 'rc_comment' => $comment, |
— | — | @@ -413,19 +420,22 @@ |
414 | 421 | 'rc_new' => 0, # obsolete |
415 | 422 | 'rc_old_len' => NULL, |
416 | 423 | 'rc_new_len' => NULL, |
| 424 | + 'rc_log_type' => $type, |
| 425 | + 'rc_log_action' => $action, |
| 426 | + 'rc_params' => $params, |
417 | 427 | ); |
418 | 428 | $rc->mExtra = array( |
419 | | - 'prefixedDBkey' => $title->getPrefixedDBkey(), |
| 429 | + 'prefixedDBkey' => $target->getPrefixedDBkey(), |
420 | 430 | 'lastTimestamp' => 0, |
421 | 431 | 'logType' => $type, |
422 | 432 | 'logAction' => $action, |
423 | | - 'logComment' => $logComment, |
| 433 | + 'logComment' => $comment, |
424 | 434 | 'logTarget' => $target, |
425 | | - 'logParams' => $params |
| 435 | + 'logParams' => $params, |
426 | 436 | ); |
427 | 437 | $rc->save(); |
428 | 438 | } |
429 | | - |
| 439 | + |
430 | 440 | # Initialises the members of this object from a mysql row object |
431 | 441 | function loadFromRow( $row ) |
432 | 442 | { |
Index: branches/robchurch/logs/includes/PatrolLog.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | public static function makeActionText( $item ) { |
43 | 43 | global $wgUser; |
44 | 44 | $skin = $wgUser->getSkin(); |
45 | | - |
| 45 | + |
46 | 46 | list( $cur, /* $prev */, $auto ) = $item->getParameters(); |
47 | 47 | # Standard link to the page in question |
48 | 48 | $link = $skin->makeLinkObj( $item->getTarget() ); |
Index: branches/robchurch/logs/includes/ChangesList.php |
— | — | @@ -248,12 +248,20 @@ |
249 | 249 | |
250 | 250 | $this->insertDateHeader($s,$rc_timestamp); |
251 | 251 | |
| 252 | + # New log entries use the standard formatter |
| 253 | + if( $rc_log_type && $rc_log_action ) { |
| 254 | + $item = LogItem::newFromRecentChange( $rc ); |
| 255 | + $s .= $item->format( LogFormatter::NO_DATE ); |
| 256 | + wfProfileOut( $fname ); |
| 257 | + return $s; |
| 258 | + } |
| 259 | + |
252 | 260 | $s .= '<li>'; |
253 | 261 | |
254 | 262 | // moved pages |
255 | 263 | if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { |
256 | 264 | $this->insertMove( $s, $rc ); |
257 | | - // log entries |
| 265 | + # Old log entries use the...old method |
258 | 266 | } elseif ( $rc_namespace == NS_SPECIAL ) { |
259 | 267 | list( $specialName, $specialSubpage ) = SpecialPage::resolveAliasWithSubpage( $rc_title ); |
260 | 268 | if ( $specialName == 'Log' ) { |
Index: branches/robchurch/logs/includes/LogItem.php |
— | — | @@ -100,6 +100,27 @@ |
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
| 104 | + * Instantiate a LogItem using data from a RecentChange |
| 105 | + * |
| 106 | + * @param RecentChange $change |
| 107 | + * @return LogItem |
| 108 | + */ |
| 109 | + public static function newFromRecentChange( $change ) { |
| 110 | + $attr =& $change->mAttribs; |
| 111 | + return new self( |
| 112 | + $attr['rc_logid'], |
| 113 | + $attr['rc_log_type'], |
| 114 | + $attr['rc_log_action'], |
| 115 | + $attr['rc_timestamp'], |
| 116 | + new LogUser( $attr['rc_user'], $attr['rc_user_text'] ), |
| 117 | + Title::makeTitleSafe( $attr['rc_namespace'], $attr['rc_title'] ), |
| 118 | + $attr['rc_comment'], |
| 119 | + $attr['rc_params'], |
| 120 | + $attr['rc_deleted'] |
| 121 | + ); |
| 122 | + } |
| 123 | + |
| 124 | + /** |
104 | 125 | * Get the log type |
105 | 126 | * |
106 | 127 | * @return string |
Index: branches/robchurch/logs/includes/LogPage.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | 'log_namespace' => $this->target->getNamespace(), |
68 | 68 | 'log_title' => $this->target->getDBkey(), |
69 | 69 | 'log_comment' => $this->comment, |
70 | | - 'log_params' => $this->params |
| 70 | + 'log_params' => $this->params, |
71 | 71 | ); |
72 | 72 | |
73 | 73 | # log_id doesn't exist on Wikimedia servers yet, and it's a tricky |
— | — | @@ -76,27 +76,23 @@ |
77 | 77 | } |
78 | 78 | $dbw->insert( 'logging', $data, $fname ); |
79 | 79 | |
80 | | - # And update recentchanges |
81 | | - if ( $this->updateRecentChanges ) { |
82 | | - $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); |
83 | | - $rcComment = $this->getRcComment(); |
84 | | - RecentChange::notifyLog( $now, $titleObj, $wgUser, $rcComment, '', |
85 | | - $this->type, $this->action, $this->target, $this->comment, $this->params ); |
| 80 | + # Update recent changes |
| 81 | + if( $this->updateRecentChanges ) { |
| 82 | + RecentChange::notifyLog( |
| 83 | + $now, |
| 84 | + $this->target, |
| 85 | + $wgUser, |
| 86 | + $this->comment, |
| 87 | + '', |
| 88 | + $this->type, |
| 89 | + $this->action, |
| 90 | + $this->params |
| 91 | + ); |
86 | 92 | } |
| 93 | + |
87 | 94 | return true; |
88 | 95 | } |
89 | 96 | |
90 | | - public function getRcComment() { |
91 | | - $rcComment = $this->actionText; |
92 | | - if( '' != $this->comment ) { |
93 | | - if ($rcComment == '') |
94 | | - $rcComment = $this->comment; |
95 | | - else |
96 | | - $rcComment .= ': ' . $this->comment; |
97 | | - } |
98 | | - return $rcComment; |
99 | | - } |
100 | | - |
101 | 97 | /** |
102 | 98 | * @static |
103 | 99 | */ |
— | — | @@ -234,7 +230,7 @@ |
235 | 231 | $this->comment = $comment; |
236 | 232 | $this->params = LogPage::makeParamBlob( $params ); |
237 | 233 | |
238 | | - $this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params ); |
| 234 | + #$this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params ); |
239 | 235 | |
240 | 236 | return $this->saveContent(); |
241 | 237 | } |