r88008 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88007‎ | r88008 | r88009 >
Date:17:11, 13 May 2011
Author:freakolowsky
Status:reverted (Comments)
Tags:
Comment:
Modified paths:
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -553,7 +553,8 @@
554554 'fields' => array(
555555 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
556556 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
557 - 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted'
 557+ 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted',
 558+ 'rc_old_len', 'rc_new_len'
558559 ),
559560 'conds' => $conds,
560561 'options' => array( 'USE INDEX' => array('revision' => $index) ),
@@ -572,21 +573,23 @@
573574 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
574575 return $queryInfo;
575576 }
576 -
577 - function getUserCond() {
 577+
 578+ function getUserCond() {
578579 $condition = array();
579580 $join_conds = array();
580581 if( $this->target == 'newbies' ) {
581 - $tables = array( 'user_groups', 'page', 'revision' );
 582+ $tables = array( 'recentchanges', 'user_groups', 'page', 'revision' );
582583 $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
583584 $condition[] = 'rev_user >' . (int)($max - $max / 100);
584585 $condition[] = 'ug_group IS NULL';
585586 $index = 'user_timestamp';
586587 # FIXME: other groups may have 'bot' rights
587588 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
 589+ $join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
588590 } else {
589 - $tables = array( 'page', 'revision' );
 591+ $tables = array( 'recentchanges', 'page', 'revision' );
590592 $condition['rev_user_text'] = $this->target;
 593+ $join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
591594 $index = 'usertext_timestamp';
592595 }
593596 if( $this->deletedOnly ) {
@@ -731,8 +734,19 @@
732735 }
733736
734737 $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
735 - $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
 738+
 739+ $calculatedSize = $row->rc_new_len - $row->rc_old_len;
 740+ $diffOut = ' . . ';
 741+ if ( $calculatedSize === 0 ) {
 742+ $diffOut .= "<span class='mw-plusminus-null'>($calculatedSize)</span>";
 743+ } elseif ( $calculatedSize > 0 ) {
 744+ $diffOut .= "<span class='mw-plusminus-pos'>(+$calculatedSize)</span>";
 745+ } else {
 746+ $diffOut .= "<span class='mw-plusminus-neg'>($calculatedSize)</span>";
 747+ }
736748
 749+ $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$diffOut}{$userlink} {$comment} {$topmarktext}";
 750+
737751 # Denote if username is redacted for this edit
738752 if( $rev->isDeleted( Revision::DELETED_USER ) ) {
739753 $ret .= " <strong>" . wfMsgHtml('rev-deleted-user-contribs') . "</strong>";

Follow-up revisions

RevisionCommit summaryAuthorDate
r88019* fixed as per comment on r88008freakolowsky21:33, 13 May 2011
r88111* added an option to toggle the display of diff size with a warning message....freakolowsky17:05, 14 May 2011
r96081* added redundand join condition for index usage as per comment on CR r88008freakolowsky06:58, 2 September 2011
r96306Revert r88008 (add size difference to Special:Contributions) and its large gr...catrope21:47, 5 September 2011
r103770(bug 24037) Add byte length of revision to Special:Contributions. Patch by Um...catrope18:17, 20 November 2011
r103993Revert r103770 (bug 24037) -- added full-page size to Special:Contribs which ...brion00:48, 23 November 2011
r112183release-notes-1.19...krinkle02:43, 23 February 2012

Comments

#Comment by Raymond (talk | contribs)   17:59, 13 May 2011

This needs better i18n support. Maybe ChangesList::showCharacterDifference() can be used? See http://translatewiki.net/wiki/Special:Contributions/FuzzyBot?uselang=fa for an example

#Comment by Freakolowsky (talk | contribs)   20:58, 13 May 2011

on it ...

#Comment by Bryan (talk | contribs)   09:58, 14 May 2011

Special:Contributions now only shows edits that are in recentchanges. I don't think there is a way to fix this without a schema change, so it should be reverted.

#Comment by Platonides (talk | contribs)   23:53, 14 May 2011

It could be done by actually calculating the number with the length of the previous revision. Although that means it's much more expensive, of course.

#Comment by Bryan (talk | contribs)   10:00, 14 May 2011

Also, "bug 24037" is insufficient for a commit summary. Please try to at least include the bug title into it, so that we don't need to click through to bugzilla to find out what the commit is supposed to do.

#Comment by Duplicatebug (talk | contribs)   10:00, 14 May 2011

Using the byte difference is expensive, because you have to join an other table. On WMF wikis the recentchanges table is only about the last 30 days ($wgRCMaxAge)

Using rev_len with Linker::formatRevisionSize looks easier.

#Comment by Freakolowsky (talk | contribs)   11:11, 14 May 2011

One way to do it without the schema change would be to add an option for this field to the page and inform the user that/if wgRCMaxAge is in effect, to expect limited results (perhaps respecting the wgMiserMode setting to avoid aditional join).

#Comment by Bryan (talk | contribs)   12:30, 14 May 2011

That could work, yes.

#Comment by Freakolowsky (talk | contribs)   20:52, 16 May 2011

Got changed in multiple following revs ... switching back to new

#Comment by Aaron Schulz (talk | contribs)   02:24, 24 June 2011

$join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );

...this is too slow. Please add on a redundant rev_timestamp = rc_timestamp condition for index usage at least.

Status & tagging log