r23461 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23460‎ | r23461 | r23462 >
Date:08:21, 27 June 2007
Author:robchurch
Status:old
Tags:
Comment:
* Update comments for the `logging` stuff in `recentchanges`
* Set appropriate columns in `recentchanges` when adding a log item there and don't mess about with the title or comment
* Use the standard formatting method when encountering a `recentchange` row with non-null log type and action column values in ChangesList
Modified paths:
  • /branches/robchurch/logs/includes/ChangesList.php (modified) (history)
  • /branches/robchurch/logs/includes/LogItem.php (modified) (history)
  • /branches/robchurch/logs/includes/LogPage.php (modified) (history)
  • /branches/robchurch/logs/includes/PatrolLog.php (modified) (history)
  • /branches/robchurch/logs/includes/RecentChange.php (modified) (history)
  • /branches/robchurch/logs/maintenance/tables.sql (modified) (history)

Diff [purge]

Index: branches/robchurch/logs/maintenance/tables.sql
@@ -848,15 +848,18 @@
849849 -- Visibility of deleted revisions, bitfield
850850 rc_deleted tinyint unsigned NOT NULL default '0',
851851
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
859862 rc_params BLOB NULL,
860 -
 863+
861864 PRIMARY KEY rc_id (rc_id),
862865 INDEX rc_timestamp (rc_timestamp),
863866 INDEX rc_namespace_title (rc_namespace, rc_title),
Index: branches/robchurch/logs/includes/RecentChange.php
@@ -25,6 +25,7 @@
2626 * rc_patrolled boolean whether or not someone has marked this edit as patrolled
2727 * rc_old_len integer byte length of the text before the edit
2828 * rc_new_len the same after the edit
 29+ * rc_params
2930 *
3031 * mExtra:
3132 * prefixedDBkey prefixed db key, used by external app via msg queue
@@ -379,27 +380,33 @@
380381 RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, true );
381382 }
382383
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 )
389399 $ip = wfGetIP();
390 - if ( !$ip ) {
391 - $ip = '';
392 - }
393 - }
394 -
395 - $rc = new RecentChange;
 400+ if( !$ip )
 401+ $ip = '';
 402+ $rc = new RecentChange();
396403 $rc->mAttribs = array(
397404 'rc_timestamp' => $timestamp,
398405 'rc_cur_time' => $timestamp,
399 - 'rc_namespace' => $title->getNamespace(),
400 - 'rc_title' => $title->getDBkey(),
 406+ 'rc_namespace' => $target->getNamespace(),
 407+ 'rc_title' => $target->getDBkey(),
401408 'rc_type' => RC_LOG,
402409 'rc_minor' => 0,
403 - 'rc_cur_id' => $title->getArticleID(),
 410+ 'rc_cur_id' => $target->getArticleID(),
404411 'rc_user' => $user->getID(),
405412 'rc_user_text' => $user->getName(),
406413 'rc_comment' => $comment,
@@ -413,19 +420,22 @@
414421 'rc_new' => 0, # obsolete
415422 'rc_old_len' => NULL,
416423 'rc_new_len' => NULL,
 424+ 'rc_log_type' => $type,
 425+ 'rc_log_action' => $action,
 426+ 'rc_params' => $params,
417427 );
418428 $rc->mExtra = array(
419 - 'prefixedDBkey' => $title->getPrefixedDBkey(),
 429+ 'prefixedDBkey' => $target->getPrefixedDBkey(),
420430 'lastTimestamp' => 0,
421431 'logType' => $type,
422432 'logAction' => $action,
423 - 'logComment' => $logComment,
 433+ 'logComment' => $comment,
424434 'logTarget' => $target,
425 - 'logParams' => $params
 435+ 'logParams' => $params,
426436 );
427437 $rc->save();
428438 }
429 -
 439+
430440 # Initialises the members of this object from a mysql row object
431441 function loadFromRow( $row )
432442 {
Index: branches/robchurch/logs/includes/PatrolLog.php
@@ -41,7 +41,7 @@
4242 public static function makeActionText( $item ) {
4343 global $wgUser;
4444 $skin = $wgUser->getSkin();
45 -
 45+
4646 list( $cur, /* $prev */, $auto ) = $item->getParameters();
4747 # Standard link to the page in question
4848 $link = $skin->makeLinkObj( $item->getTarget() );
Index: branches/robchurch/logs/includes/ChangesList.php
@@ -248,12 +248,20 @@
249249
250250 $this->insertDateHeader($s,$rc_timestamp);
251251
 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+
252260 $s .= '<li>';
253261
254262 // moved pages
255263 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
256264 $this->insertMove( $s, $rc );
257 - // log entries
 265+ # Old log entries use the...old method
258266 } elseif ( $rc_namespace == NS_SPECIAL ) {
259267 list( $specialName, $specialSubpage ) = SpecialPage::resolveAliasWithSubpage( $rc_title );
260268 if ( $specialName == 'Log' ) {
Index: branches/robchurch/logs/includes/LogItem.php
@@ -100,6 +100,27 @@
101101 }
102102
103103 /**
 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+ /**
104125 * Get the log type
105126 *
106127 * @return string
Index: branches/robchurch/logs/includes/LogPage.php
@@ -66,7 +66,7 @@
6767 'log_namespace' => $this->target->getNamespace(),
6868 'log_title' => $this->target->getDBkey(),
6969 'log_comment' => $this->comment,
70 - 'log_params' => $this->params
 70+ 'log_params' => $this->params,
7171 );
7272
7373 # log_id doesn't exist on Wikimedia servers yet, and it's a tricky
@@ -76,27 +76,23 @@
7777 }
7878 $dbw->insert( 'logging', $data, $fname );
7979
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+ );
8692 }
 93+
8794 return true;
8895 }
8996
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 -
10197 /**
10298 * @static
10399 */
@@ -234,7 +230,7 @@
235231 $this->comment = $comment;
236232 $this->params = LogPage::makeParamBlob( $params );
237233
238 - $this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params );
 234+ #$this->actionText = LogPage::actionText( $this->type, $action, $target, NULL, $params );
239235
240236 return $this->saveContent();
241237 }

Status & tagging log