*Get rev_len to carry across delete/undelete
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 13 Mar 2007 23:28:34 +0000 (23:28 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 13 Mar 2007 23:28:34 +0000 (23:28 +0000)
includes/Article.php
includes/Revision.php
includes/SpecialUndelete.php

index a729bcb..3c8d10e 100644 (file)
@@ -2078,6 +2078,7 @@ class Article {
                                'ar_text_id'    => 'rev_text_id',
                                'ar_text'       => '\'\'', // Be explicit to appease
                                'ar_flags'      => '\'\'', // MySQL's "strict mode"...
+                               'ar_len'                => 'rev_len'
                        ), array(
                                'page_id' => $id,
                                'page_id = rev_page'
index 34210ee..92ea636 100644 (file)
@@ -11,7 +11,6 @@ class Revision {
        const DELETED_COMMENT = 2;
        const DELETED_USER = 4;
     const DELETED_RESTRICTED = 8;
-    const DELETED_NAME = 16;
        
        /**
         * Load a page revision from a given revision ID number.
@@ -317,7 +316,8 @@ class Revision {
                        $this->mMinorEdit = isset( $row['minor_edit'] ) ? intval( $row['minor_edit'] ) : 0;
                        $this->mTimestamp = isset( $row['timestamp']  ) ? strval( $row['timestamp']  ) : wfTimestamp( TS_MW );
                        $this->mDeleted   = isset( $row['deleted']    ) ? intval( $row['deleted']    ) : 0;
-
+                       $this->mSize      = isset( $row['len']        ) ? intval( $row['len']        ) : 0;
+                       
                        // Enforce spacing trimming on supplied text
                        $this->mComment   = isset( $row['comment']    ) ?  trim( strval( $row['comment'] ) ) : null;
                        $this->mText      = isset( $row['text']       ) ? rtrim( strval( $row['text']    ) ) : null;
@@ -325,8 +325,9 @@ class Revision {
 
                        $this->mTitle     = null; # Load on demand if needed
                        $this->mCurrent   = false;
-
-                       $this->mSize      = is_null($this->mText) ? null : strlen($this->mText);
+                       # If we still have no len_size, see it we have the text to figure it out
+                       if ( !$this->mSize )
+                               $this->mSize      = is_null($this->mText) ? null : strlen($this->mText);
                } else {
                        throw new MWException( 'Revision constructor passed invalid row format.' );
                }
@@ -711,7 +712,7 @@ class Revision {
                                'rev_user_text'  => $this->mUserText,
                                'rev_timestamp'  => $dbw->timestamp( $this->mTimestamp ),
                                'rev_deleted'    => $this->mDeleted,
-                               'rev_len'        => strlen($this->mText),
+                               'rev_len'            => ( $this->mSize ) ? $this->mSize : strlen($this->mText),
                        ), $fname
                );
 
index ab7d32f..85bb194 100644 (file)
@@ -99,7 +99,7 @@ class PageArchive {
        function listRevisions() {
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( 'archive',
-                       array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment' ),
+                       array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len' ),
                        array( 'ar_namespace' => $this->title->getNamespace(),
                               'ar_title' => $this->title->getDBkey() ),
                        'PageArchive::listRevisions',
@@ -170,7 +170,8 @@ class PageArchive {
                                'ar_timestamp',
                                'ar_minor_edit',
                                'ar_flags',
-                               'ar_text_id' ),
+                               'ar_text_id',
+                               'ar_len' ),
                        array( 'ar_namespace' => $this->title->getNamespace(),
                               'ar_title' => $this->title->getDbkey(),
                               'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
@@ -373,7 +374,8 @@ class PageArchive {
                                'ar_timestamp',
                                'ar_minor_edit',
                                'ar_flags',
-                               'ar_text_id' ),
+                               'ar_text_id',
+                               'ar_len' ),
                        /* WHERE */ array(
                                'ar_namespace' => $this->title->getNamespace(),
                                'ar_title'     => $this->title->getDBkey(),
@@ -413,6 +415,7 @@ class PageArchive {
                                'timestamp'  => $row->ar_timestamp,
                                'minor_edit' => $row->ar_minor_edit,
                                'text_id'    => $row->ar_text_id,
+                               'len'            => $row->ar_len
                                ) );
                        $revision->insertOn( $dbw );
                        $restored++;
@@ -768,8 +771,14 @@ class UndeleteForm {
                                        $pageLink = $wgLang->timeanddate( $ts, true );
                                }
                                $userLink = $sk->userLink( $row->ar_user, $row->ar_user_text ) . $sk->userToolLinks( $row->ar_user, $row->ar_user_text );
+                               if (!is_null($size = $row->ar_len)) {
+                                       if ($size == 0)
+                                       $stxt = wfMsgHtml('historyempty');
+                               else
+                                       $stxt = wfMsgHtml('historysize', $wgLang->formatNum( $size ) );
+                               }
                                $comment = $sk->commentBlock( $row->ar_comment );
-                               $wgOut->addHTML( "<li>$checkBox $pageLink . . $userLink $comment</li>\n" );
+                               $wgOut->addHTML( "<li>$checkBox $pageLink . . $userLink $stxt $comment</li>\n" );
        
                        }
                        $revisions->free();