* (bug 1723) Article size in history
authorRiver Tarnell <river@users.mediawiki.org>
Thu, 8 Mar 2007 03:07:58 +0000 (03:07 +0000)
committerRiver Tarnell <river@users.mediawiki.org>
Thu, 8 Mar 2007 03:07:58 +0000 (03:07 +0000)
RELEASE-NOTES
includes/PageHistory.php
includes/Revision.php
languages/messages/MessagesEn.php

index 9a254c2..095a89a 100644 (file)
@@ -253,6 +253,7 @@ lighter making things easier to read.
 * (bug 9097) column "pr_pagetype" does not exist
 * (bug 9217) Balance wfProfile calls in Skin::outputPage
 * (bug 9222) PostgreSQL updater should not be version-specific
+* (bug 1723) Article size in history
 
 == Languages updated ==
 
index b397e8c..2c035c3 100644 (file)
@@ -219,6 +219,15 @@ class PageHistory {
                if( $row->rev_minor_edit ) {
                        $s .= ' ' . wfElement( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') );
                }
+
+               if (!is_null($size = $rev->getSize())) {
+                       if ($size == 0)
+                               $stxt = wfMsgHtml('historyempty');
+                       else
+                               $stxt = wfMsgHtml('historysize', $size);
+                       $s .= " <span class=\"history-size\">$stxt</span>";
+               }
+
                #getComment is safe, but this is better formatted
                if( $rev->isDeleted( Revision::DELETED_COMMENT ) ) {
                        $s .= " <span class=\"history-deleted\"><span class=\"comment\">" .
@@ -379,7 +388,7 @@ class PageHistory {
                $res = $dbr->select(
                        'revision',
                        array('rev_id', 'rev_page', 'rev_text_id', 'rev_user', 'rev_comment', 'rev_user_text',
-                               'rev_timestamp', 'rev_minor_edit', 'rev_deleted'),
+                               'rev_timestamp', 'rev_minor_edit', 'rev_deleted', 'rev_len'),
                        array_merge(array("rev_page=$page_id"), $offsets),
                        $fname,
                        array('ORDER BY' => "rev_timestamp $dirs",
@@ -522,7 +531,7 @@ class PageHistoryPager extends ReverseChronologicalPager {
                return array(
                        'tables' => 'revision',
                        'fields' => array('rev_id', 'rev_page', 'rev_text_id', 'rev_user', 'rev_comment', 'rev_user_text',
-                               'rev_timestamp', 'rev_minor_edit', 'rev_deleted'),
+                               'rev_timestamp', 'rev_minor_edit', 'rev_deleted', 'rev_len'),
                        'conds' => array('rev_page' => $this->mPageHistory->mTitle->getArticleID() ),
                        'options' => array( 'USE INDEX' => 'page_timestamp' )
                );
index 7526a54..3dcb471 100644 (file)
@@ -239,7 +239,8 @@ class Revision {
                               'rev_user',
                               'rev_minor_edit',
                               'rev_timestamp',
-                              'rev_deleted' ),
+                              'rev_deleted',
+                              'rev_len' ),
                        $conditions,
                        'Revision::fetchRow',
                        array( 'LIMIT' => 1 ) );
@@ -263,6 +264,11 @@ class Revision {
                        $this->mTimestamp =         $row->rev_timestamp;
                        $this->mDeleted   = intval( $row->rev_deleted );
 
+                       if (is_null($row->rev_len))
+                               $this->mSize = null;
+                       else
+                               $this->mSize = intval( $row->rev_len ); 
+
                        if( isset( $row->page_latest ) ) {
                                $this->mCurrent   = ( $row->rev_id == $row->page_latest );
                                $this->mTitle     = Title::makeTitle( $row->page_namespace,
@@ -300,6 +306,8 @@ class Revision {
 
                        $this->mTitle     = null; # Load on demand if needed
                        $this->mCurrent   = false;
+
+                       $this->mSize      = is_null($this->mText) ? null : strlen($this->mText);
                } else {
                        throw new MWException( 'Revision constructor passed invalid row format.' );
                }
@@ -323,6 +331,13 @@ class Revision {
                return $this->mTextId;
        }
 
+       /**
+        * Returns the length of the text in this revision, or null if unknown.
+        */
+       function getSize() {
+               return $this->mSize;
+       }
+
        /**
         * Returns the title of the page associated with this entry.
         * @return Title
index 8853737..a727925 100644 (file)
@@ -1077,7 +1077,8 @@ there may be details in the [{{fullurl:Special:Log/delete|page={{PAGENAMEE}}}} d
 </div>',
 #'rev-delundel' => 'del/undel',
 'rev-delundel' => 'show/hide',
-
+'historysize' => '($1 bytes)',
+'historyempty' => '(empty)',
 
 'history-feed-title' => 'Revision history',
 'history-feed-description'     => 'Revision history for this page on the wiki',