r95496 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95495‎ | r95496 | r95497 >
Date:17:35, 25 August 2011
Author:reedy
Status:reverted (Comments)
Tags:
Comment:
Revert r8811

Reverting followups r88117, 88252
Modified paths:
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -2033,7 +2033,6 @@
20342034 'sp-contributions-explain',
20352035 'sp-contributions-footer',
20362036 'sp-contributions-footer-anon',
2037 - 'sp-contributions-showsizediff',
20382037 ),
20392038 'whatlinkshere' => array(
20402039 'whatlinkshere',
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -69,7 +69,6 @@
7070 $this->opts['limit'] = $wgRequest->getInt( 'limit', $wgUser->getOption('rclimit') );
7171 $this->opts['target'] = $target;
7272 $this->opts['topOnly'] = $wgRequest->getBool( 'topOnly' );
73 - $this->opts['showSizeDiff'] = $wgRequest->getBool( 'showSizeDiff' );
7473
7574 $nt = Title::makeTitleSafe( NS_USER, $target );
7675 if( !$nt ) {
@@ -166,7 +165,6 @@
167166 'month' => $this->opts['month'],
168167 'deletedOnly' => $this->opts['deletedOnly'],
169168 'topOnly' => $this->opts['topOnly'],
170 - 'showSizeDiff' => $this->opts['showSizeDiff'],
171169 ) );
172170 if( !$pager->getNumRows() ) {
173171 $wgOut->addWikiMsg( 'nocontribs', $target );
@@ -379,14 +377,10 @@
380378 $this->opts['topOnly'] = false;
381379 }
382380
383 - if( !isset( $this->opts['showSizeDiff'] ) ) {
384 - $this->opts['showSizeDiff'] = !$wgMiserMode;
385 - }
386 -
387381 $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
388382
389383 # Add hidden params for tracking except for parameters in $skipParameters
390 - $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'showSizeDiff' );
 384+ $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly' );
391385 foreach ( $this->opts as $name => $value ) {
392386 if( in_array( $name, $skipParameters ) ) {
393387 continue;
@@ -397,13 +391,10 @@
398392 $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagFilter'] );
399393
400394 $fNS = '';
401 - $fShowDiff = '';
402395 if ( !$wgMiserMode ) {
403396 $fNS = Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
404 - Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
405 - Xml::namespaceSelector( $this->opts['namespace'], '' )
406 - );
407 - $fShowDiff = Xml::checkLabel( wfMsg( 'sp-contributions-showsizediff' ), 'showSizeDiff', 'mw-show-size-diff', $this->opts['showSizeDiff'] );
 397+ Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' . Xml::namespaceSelector( $this->opts['namespace'], '' )
 398+ );
408399 }
409400
410401 $f .= Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) .
@@ -420,7 +411,6 @@
421412 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . '<br />' .
422413 Xml::tags( 'p', null, Xml::checkLabel( wfMsg( 'sp-contributions-toponly' ),
423414 'topOnly', 'mw-show-top-only', $this->opts['topOnly'] ) ) .
424 - $fShowDiff.
425415 ( $tagFilter ? Xml::tags( 'p', null, implode( '&#160;', $tagFilter ) ) : '' ) .
426416 Html::rawElement( 'p', array( 'style' => 'white-space: nowrap' ),
427417 Xml::dateMenu( $this->opts['year'], $this->opts['month'] ) . ' ' .
@@ -461,7 +451,6 @@
462452
463453 $this->deletedOnly = !empty( $options['deletedOnly'] );
464454 $this->topOnly = !empty( $options['topOnly'] );
465 - $this->showSizeDiff = !empty( $options['showSizeDiff'] );
466455
467456 $year = isset( $options['year'] ) ? $options['year'] : false;
468457 $month = isset( $options['month'] ) ? $options['month'] : false;
@@ -481,7 +470,7 @@
482471 }
483472
484473 function getQueryInfo() {
485 - global $wgUser, $wgMiserMode;
 474+ global $wgUser;
486475 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
487476
488477 $conds = array_merge( $userCond, $this->getNamespaceCond() );
@@ -497,18 +486,17 @@
498487 $fields = array(
499488 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
500489 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
501 - 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted',
502 - 'rev_len'
 490+ 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted'
503491 );
504 - if ( $this->showSizeDiff && !$wgMiserMode ) {
505 - $fields = array_merge( $fields, array( 'rc_old_len', 'rc_new_len' ) );
506 - array_unshift( $tables, 'recentchanges' );
507 - $join_cond['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
508 - }
509492
510493 $queryInfo = array(
511494 'tables' => $tables,
512 - 'fields' => $fields,
 495+ 'fields' => array(
 496+ 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
 497+ 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
 498+ 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted',
 499+ 'rc_old_len', 'rc_new_len'
 500+ ),
513501 'conds' => $conds,
514502 'options' => array( 'USE INDEX' => array('revision' => $index) ),
515503 'join_conds' => $join_cond
@@ -531,16 +519,18 @@
532520 $join_conds = array();
533521
534522 if( $this->target == 'newbies' ) {
535 - $tables = array( 'user_groups', 'page', 'revision' );
 523+ $tables = array( 'recentchanges', 'user_groups', 'page', 'revision' );
536524 $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
537525 $condition[] = 'rev_user >' . (int)($max - $max / 100);
538526 $condition[] = 'ug_group IS NULL';
539527 $index = 'user_timestamp';
540528 # @todo FIXME: Other groups may have 'bot' rights
541529 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
 530+ $join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
542531 } else {
543 - $tables = array( 'page', 'revision' );
 532+ $tables = array( 'recentchanges', 'page', 'revision' );
544533 $condition['rev_user_text'] = $this->target;
 534+ $join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
545535 $index = 'usertext_timestamp';
546536 }
547537 if( $this->deletedOnly ) {
@@ -689,7 +679,7 @@
690680
691681
692682 $diffOut = ' . . ' . $wgLang->getDirMark() . ( $this->showSizeDiff ?
693 - ChangesList::showCharacterDifference( $row->rc_old_len, $row->rc_new_len ) : Linker::formatRevisionSize( $row->rev_len ) );
 683+ ChangesList::showCharacterDifference( $row->rc_old_len, $row->rc_new_len ) : '' );
694684
695685 $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$diffOut}{$userlink} {$comment} {$topmarktext}";
696686
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3007,6 +3007,7 @@
30083008 'sp-contributions-footer' => '-', # do not translate or duplicate this message to other languages
30093009 'sp-contributions-footer-anon' => '-', # do not translate or duplicate this message to other languages
30103010 'sp-contributions-showsizediff' => 'Display difference in page size',
 3011+'sp-contributions-showsizediff-warn' => 'This instance has recent changes log limited to $1 . If you use this option, pages not in this log will not be displayed',
30113012
30123013 # What links here
30133014 'whatlinkshere' => 'What links here',

Follow-up revisions

RevisionCommit summaryAuthorDate
r95506fu r95496: remove the messages reallyraymond19:44, 25 August 2011
r95524Fux PHP Notice: Undefined property: ContribsPager::$showSizeDiff in /www/w/in...reedy21:22, 25 August 2011
r95553Fix another remnant of r95496reedy11:15, 26 August 2011
r96005Followup r95496, remove duplicate $fields definitionreedy16:01, 1 September 2011
r96090Revert r95496, r95506, r95524, r95553, r96005reedy11:04, 2 September 2011
r96306Revert r88008 (add size difference to Special:Contributions) and its large gr...catrope21:47, 5 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r88111* added an option to toggle the display of diff size with a warning message....freakolowsky17:05, 14 May 2011
r88117* added alternative revison size display if diff size is not selectedfreakolowsky22:06, 14 May 2011
r88252Remove verboseness (image and infobox) in Special:Contributions for diff size...siebrand17:51, 16 May 2011

Comments

#Comment by Reedy (talk | contribs)   17:42, 25 August 2011
#Comment by Raymond (talk | contribs)   18:32, 25 August 2011

Why adding a message in MessagesEn.php instead of removing the one from messages.inc?

-		'sp-contributions-showsizediff',
+'sp-contributions-showsizediff-warn'   => 'This instance has recent changes log limited to $1 . If you use this option, pages not in this log will not be displayed',
#Comment by Reedy (talk | contribs)   18:59, 25 August 2011

God know, svn reverted it fine, feel free to delete both messages. I'm away from computer till later

#Comment by Raymond (talk | contribs)   19:45, 25 August 2011
#Comment by Raymond (talk | contribs)   20:17, 25 August 2011

PHP Notice: Undefined property: ContribsPager::$showSizeDiff in /www/w/includes/specials/SpecialContributions.php on line 681

#Comment by 😂 (talk | contribs)   03:12, 26 August 2011

Also: getting an undefined index on line 129 since $this->opts['showSizeDiff'] is never set.

#Comment by MZMcBride (talk | contribs)   03:54, 31 August 2011

I don't think this is resolved. I'm running r95814 on my test wiki and pagination of my contributions is completely broken due to this revision. When I sync the previous revision of SpecialContributions.php (r93246) to my server, pagination works again and I can see my older contributions.

#Comment by Reedy (talk | contribs)   14:42, 31 August 2011

Works fine for me on trunk...

#Comment by Reedy (talk | contribs)   14:45, 31 August 2011

And for Roan/Niklas

#Comment by MZMcBride (talk | contribs)   04:24, 31 August 2011

So there were undisclosed changes in some of the previous revisions that were accidentally reverted here. Basically what needs to happen is...

		$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'
		);

		$queryInfo = array(
			'tables' => $tables,
			'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',
				'rc_old_len', 'rc_new_len'
			),
			'conds' => $conds,
			'options' => array( 'USE INDEX' => array('revision' => $index) ),
			'join_conds' => $join_cond
		);

This section needs to be made sane. You're defining $fields twice, once with 'rc_old_len' and 'rc_new_len' and once without. One possible solution:

		$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'
		);

		$queryInfo = array(
			'tables' => $tables,
			'fields' => $fields,
			'conds' => $conds,
			'options' => array( 'USE INDEX' => array('revision' => $index) ),
			'join_conds' => $join_cond
		);

Later in the file...

		if( $this->target == 'newbies' ) {
			$tables = array( 'recentchanges', 'user_groups', 'page', 'revision' );
			$max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
			$condition[] = 'rev_user >' . (int)($max - $max / 100);
			$condition[] = 'ug_group IS NULL';
			$index = 'user_timestamp';
			# @todo FIXME: Other groups may have 'bot' rights
			$join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
			$join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
		} else {
			$tables = array( 'recentchanges', 'page', 'revision' );
			$condition['rev_user_text'] = $this->target;
			$join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
			$index = 'usertext_timestamp';
		}

This is still doing an inner join on rev_id = rc_this_oldid. Don't do this. This could be switched to something like...

		if( $this->target == 'newbies' ) {
			$tables = array( 'recentchanges', 'user_groups', 'page', 'revision' );
			$max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
			$condition[] = 'rev_user >' . (int)($max - $max / 100);
			$condition[] = 'ug_group IS NULL';
			$index = 'user_timestamp';
			# @todo FIXME: Other groups may have 'bot' rights
			$join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
			$join_conds['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
		} else {
			$tables = array( 'page', 'revision' );
			$condition['rev_user_text'] = $this->target;
			$index = 'usertext_timestamp';
		}

And finally, this part needs a healthy evaluation:

		$diffOut = ' . . ' . $wgLang->getDirMark() .
			ChangesList::showCharacterDifference( $row->rc_old_len, $row->rc_new_len );

Thanks to Fran Rogers for helping me debug this mess.

#Comment by Reedy (talk | contribs)   14:44, 31 August 2011

The inner join on rev_id = rc_this_oldid is still there in your code

#Comment by MZMcBride (talk | contribs)   16:32, 31 August 2011

In the "if ... newbies" branch? It has to be, I think?

#Comment by Reedy (talk | contribs)   14:48, 31 August 2011

ALSO!

Stuff like this is much more useful as a patch

#Comment by MZMcBride (talk | contribs)   16:30, 31 August 2011

Bite me.

#Comment by MZMcBride (talk | contribs)   04:37, 31 August 2011

Also, are there unit tests for Special:Contributions? All of this newbie / diffchange / latest revisions only code seems very fragile.

#Comment by Reedy (talk | contribs)   11:52, 31 August 2011

No, there aren't any unit tests for Special:Contributions.

If I've made a b0rked merge, I'm happy to revert out and try again. If there are other issues with the code, that's a separate issue, and shouldn't really be part of the revert and merge...

#Comment by MZMcBride (talk | contribs)   16:35, 31 August 2011

As I said above, this is actively breaking Special:Contributions as of r95814. It's joining against recentchanges, making viewing older contributions impossible. Current example: <http://pruebita.com/wiki/Special:Contributions/MZMcBride>. I have contributions on this test site dating back for years, but it stops showing results from before June 2011. This needs to be fixed as soon as possible.

#Comment by Catrope (talk | contribs)   17:29, 31 August 2011

Aaah, yeah I guess changing INNER JOIN to LEFT JOIN might fix that.

#Comment by Reedy (talk | contribs)   08:04, 1 September 2011

How did this ever work before then? Looking at r88111, and as such, this revision, the reversion is just adding back the lines removed by r88111.

#Comment by MZMcBride (talk | contribs)   02:27, 2 September 2011

Not to be rude, but if you spent a minute reading through the code, you'd be able to see what went wrong. r88111 wasn't the first revision and it wasn't what broke Special:Contributions. r88008 broke Special:Contributions. r88111 fixed Special:Contributions (along with attempting to fix a separate issue). When you reverted r88111, you re-broke Special:Contributions. You can read all about this in the code comments of this revision, r88111, and r88008.

I already went through and described, in detail, what needs to be done in order to get Special:Contributions working again. I've also provided a working demonstration of the brokenness. Short of getting commit access and fixing the problem myself, I'm not sure what more I can really do here.

#Comment by Reedy (talk | contribs)   11:01, 2 September 2011

Doesn't really help much when revisions aren't tagged as followups and/or mentioned in commit summaries

#Comment by Catrope (talk | contribs)   21:49, 5 September 2011

Fixed properly in r96306 by reverting the entire r88008 saga.

Status & tagging log