From 399e139bed7cb2eafb76cf09dbfb9cbb2592192d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 13 Mar 2007 23:28:34 +0000 Subject: [PATCH] *Get rev_len to carry across delete/undelete --- includes/Article.php | 1 + includes/Revision.php | 11 ++++++----- includes/SpecialUndelete.php | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index a729bcb59e..3c8d10e094 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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' diff --git a/includes/Revision.php b/includes/Revision.php index 34210ee938..92ea6361f1 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -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 ); diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index ab7d32f635..85bb1943fa 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -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( "
  • $checkBox $pageLink . . $userLink $comment
  • \n" ); + $wgOut->addHTML( "
  • $checkBox $pageLink . . $userLink $stxt $comment
  • \n" ); } $revisions->free(); -- 2.20.1