From: Aaron Schulz Date: Thu, 15 Sep 2011 19:36:12 +0000 (+0000) Subject: (bug 30903) Show diff size in contribution list. Works via batched query using rev_pa... X-Git-Tag: 1.31.0-rc.0~27628 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=a9699804679442a1b9c399320f97ee9fe7d72208;p=lhc%2Fweb%2Fwiklou.git (bug 30903) Show diff size in contribution list. Works via batched query using rev_parent_id. This is the original change diff and won't the current "diff to previous rev according to rev_page,rev_timestamp" size for edge cases of selective undeletion (revdelete should be used instead anyway) or history merges. --- diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index 38180606be..2d220d6b57 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -485,7 +485,8 @@ class ContribsPager extends ReverseChronologicalPager { 'fields' => array( 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect', 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment', - 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted' + 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted', + 'rev_len', 'rev_parent_id' ), 'conds' => $conds, 'options' => array( 'USE INDEX' => array('revision' => $index) ), @@ -551,6 +552,44 @@ class ContribsPager extends ReverseChronologicalPager { return "\n"; } + function getBody() { + global $wgRCShowChangedSize; + if( !$this->mQueryDone ) { + $this->doQuery(); + } + $this->mParentLens = array(); + if( $wgRCShowChangedSize ) { + $this->mResult->rewind(); + $revIds = array(); + foreach( $this->mResult as $row ) { + $revIds[] = $row->rev_parent_id; + } + $this->mParentLens = $this->getParentLengths( $revIds ); + $this->mResult->rewind(); + } + return parent::getBody(); + } + + /* + * Do a batched query to get the parent revision lengths + */ + private function getParentLengths( array $revIds ) { + $revLens = array(); + if ( !$revIds ) { + return $revLens; // empty + } + wfProfileIn( __METHOD__ ); + $res = $this->getDatabase()->select( 'revision', + array( 'rev_id', 'rev_len' ), + array( 'rev_id' => $revIds ), + __METHOD__ ); + foreach( $res as $row ) { + $revLens[$row->rev_id] = $row->rev_len; + } + wfProfileOut( __METHOD__ ); + return $revLens; + } + /** * Generates each row in the contributions list. * @@ -609,6 +648,13 @@ class ContribsPager extends ReverseChronologicalPager { array( 'action' => 'history' ) ); + if ( isset( $this->mParentLens[$row->rev_parent_id] ) ) { + $chardiff = ' . . ' . ChangesList::showCharacterDifference( + $this->mParentLens[$row->rev_parent_id], $row->rev_len ) . ' . . '; + } else { + $chardiff = ''; + } + $comment = $wgLang->getDirMark() . $sk->revComment( $rev, false, true ); $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true ); if( $rev->userCan( Revision::DELETED_TEXT ) ) { @@ -664,7 +710,7 @@ class ContribsPager extends ReverseChronologicalPager { } $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')'; - $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}"; + $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag}{$chardiff} {$link}{$userlink} {$comment} {$topmarktext}"; # Denote if username is redacted for this edit if( $rev->isDeleted( Revision::DELETED_USER ) ) {