r20413 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20412‎ | r20413 | r20414 >
Date:23:28, 13 March 2007
Author:aaron
Status:old
Tags:
Comment:
*Get rev_len to carry across delete/undelete
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Revision.php (modified) (history)
  • /trunk/phase3/includes/SpecialUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -2078,6 +2078,7 @@
20792079 'ar_text_id' => 'rev_text_id',
20802080 'ar_text' => '\'\'', // Be explicit to appease
20812081 'ar_flags' => '\'\'', // MySQL's "strict mode"...
 2082+ 'ar_len' => 'rev_len'
20822083 ), array(
20832084 'page_id' => $id,
20842085 'page_id = rev_page'
Index: trunk/phase3/includes/Revision.php
@@ -11,7 +11,6 @@
1212 const DELETED_COMMENT = 2;
1313 const DELETED_USER = 4;
1414 const DELETED_RESTRICTED = 8;
15 - const DELETED_NAME = 16;
1615
1716 /**
1817 * Load a page revision from a given revision ID number.
@@ -317,7 +316,8 @@
318317 $this->mMinorEdit = isset( $row['minor_edit'] ) ? intval( $row['minor_edit'] ) : 0;
319318 $this->mTimestamp = isset( $row['timestamp'] ) ? strval( $row['timestamp'] ) : wfTimestamp( TS_MW );
320319 $this->mDeleted = isset( $row['deleted'] ) ? intval( $row['deleted'] ) : 0;
321 -
 320+ $this->mSize = isset( $row['len'] ) ? intval( $row['len'] ) : 0;
 321+
322322 // Enforce spacing trimming on supplied text
323323 $this->mComment = isset( $row['comment'] ) ? trim( strval( $row['comment'] ) ) : null;
324324 $this->mText = isset( $row['text'] ) ? rtrim( strval( $row['text'] ) ) : null;
@@ -325,8 +325,9 @@
326326
327327 $this->mTitle = null; # Load on demand if needed
328328 $this->mCurrent = false;
329 -
330 - $this->mSize = is_null($this->mText) ? null : strlen($this->mText);
 329+ # If we still have no len_size, see it we have the text to figure it out
 330+ if ( !$this->mSize )
 331+ $this->mSize = is_null($this->mText) ? null : strlen($this->mText);
331332 } else {
332333 throw new MWException( 'Revision constructor passed invalid row format.' );
333334 }
@@ -711,7 +712,7 @@
712713 'rev_user_text' => $this->mUserText,
713714 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ),
714715 'rev_deleted' => $this->mDeleted,
715 - 'rev_len' => strlen($this->mText),
 716+ 'rev_len' => ( $this->mSize ) ? $this->mSize : strlen($this->mText),
716717 ), $fname
717718 );
718719
Index: trunk/phase3/includes/SpecialUndelete.php
@@ -99,7 +99,7 @@
100100 function listRevisions() {
101101 $dbr = wfGetDB( DB_SLAVE );
102102 $res = $dbr->select( 'archive',
103 - array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment' ),
 103+ array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len' ),
104104 array( 'ar_namespace' => $this->title->getNamespace(),
105105 'ar_title' => $this->title->getDBkey() ),
106106 'PageArchive::listRevisions',
@@ -170,7 +170,8 @@
171171 'ar_timestamp',
172172 'ar_minor_edit',
173173 'ar_flags',
174 - 'ar_text_id' ),
 174+ 'ar_text_id',
 175+ 'ar_len' ),
175176 array( 'ar_namespace' => $this->title->getNamespace(),
176177 'ar_title' => $this->title->getDbkey(),
177178 'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
@@ -373,7 +374,8 @@
374375 'ar_timestamp',
375376 'ar_minor_edit',
376377 'ar_flags',
377 - 'ar_text_id' ),
 378+ 'ar_text_id',
 379+ 'ar_len' ),
378380 /* WHERE */ array(
379381 'ar_namespace' => $this->title->getNamespace(),
380382 'ar_title' => $this->title->getDBkey(),
@@ -413,6 +415,7 @@
414416 'timestamp' => $row->ar_timestamp,
415417 'minor_edit' => $row->ar_minor_edit,
416418 'text_id' => $row->ar_text_id,
 419+ 'len' => $row->ar_len
417420 ) );
418421 $revision->insertOn( $dbw );
419422 $restored++;
@@ -768,8 +771,14 @@
769772 $pageLink = $wgLang->timeanddate( $ts, true );
770773 }
771774 $userLink = $sk->userLink( $row->ar_user, $row->ar_user_text ) . $sk->userToolLinks( $row->ar_user, $row->ar_user_text );
 775+ if (!is_null($size = $row->ar_len)) {
 776+ if ($size == 0)
 777+ $stxt = wfMsgHtml('historyempty');
 778+ else
 779+ $stxt = wfMsgHtml('historysize', $wgLang->formatNum( $size ) );
 780+ }
772781 $comment = $sk->commentBlock( $row->ar_comment );
773 - $wgOut->addHTML( "<li>$checkBox $pageLink . . $userLink $comment</li>\n" );
 782+ $wgOut->addHTML( "<li>$checkBox $pageLink . . $userLink $stxt $comment</li>\n" );
774783
775784 }
776785 $revisions->free();