r45980 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r45979 | r45980 (on ViewVC) | r45981 >
Date:21:38, 21 January 2009
Author:werdna
Status:deferred
Tags:
Comment:Code style: use arrays, instead of by-ref parameters for out-parameters.
Modified paths:

Diff [purge]

Index: branches/change-tagging/phase3/includes/ChangeTags.php
===================================================================
--- branches/change-tagging/phase3/includes/ChangeTags.php	(revision 45979)
+++ branches/change-tagging/phase3/includes/ChangeTags.php	(revision 45980)
@@ -4,9 +4,11 @@
 	die;
 
 class ChangeTags {
-	static function formatSummaryRow( $tags, $page, &$classes ) {
+	static function formatSummaryRow( $tags, $page ) {
 		if (!$tags)
-			return '';
+			return array('',array());
+
+		$classes = array();
 		
 		$tags = explode( ',', $tags );
 		$displayTags = array();
@@ -19,7 +21,7 @@
 			$classes[] = "mw-tag-$tag";
 		}
 
-		return '(' . implode( ', ', $displayTags ) . ')';
+		return array( '(' . implode( ', ', $displayTags ) . ')', $classes );
 	}
 
 	## Basic utility method to add tags to a particular change, given its rc_id, rev_id and/or log_id.
Index: branches/change-tagging/phase3/includes/LogEventsList.php
===================================================================
--- branches/change-tagging/phase3/includes/LogEventsList.php	(revision 45979)
+++ branches/change-tagging/phase3/includes/LogEventsList.php	(revision 45980)
@@ -360,7 +360,8 @@
 		}
 
 		// Any tags...
-		$tagDisplay = ChangeTags::formatSummaryRow( $row->ts_tags, 'logevent', &$classes );
+		list($tagDisplay, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'logevent' );
+		$classes = array_merge( $classes, $newClasses );
 
 		if( $revert != '' ) {
 			$revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>';
Index: branches/change-tagging/phase3/includes/ChangesList.php
===================================================================
--- branches/change-tagging/phase3/includes/ChangesList.php	(revision 45979)
+++ branches/change-tagging/phase3/includes/ChangesList.php	(revision 45980)
@@ -386,7 +386,9 @@
 		}
 		
 		# Tags, if any.
-		$s .= ' ' . ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist', &$classes);
+		list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' );
+		$classes = array_merge( $classes, $newClasses );
+		$s .= ' ' . $tagSummary;
 
 		## Classes
 		$classes = implode( ' ', $classes );
Index: branches/change-tagging/phase3/includes/specials/SpecialNewpages.php
===================================================================
--- branches/change-tagging/phase3/includes/specials/SpecialNewpages.php	(revision 45979)
+++ branches/change-tagging/phase3/includes/specials/SpecialNewpages.php	(revision 45980)
@@ -266,7 +266,8 @@
 			$classes[] = 'not-patrolled';
 
 		# Tags, if any.
-		$tagDisplay = ChangeTags::formatSummaryRow( $result->ts_tags, 'newpages', &$classes );
+		list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( $result->ts_tags, 'newpages' );
+		$classes = array_merge( $classes, $newClasses );
 
 		$css = count($classes) ? ' class="'.implode( " ", $classes).'"' : '';
 
Index: branches/change-tagging/phase3/includes/specials/SpecialContributions.php
===================================================================
--- branches/change-tagging/phase3/includes/specials/SpecialContributions.php	(revision 45979)
+++ branches/change-tagging/phase3/includes/specials/SpecialContributions.php	(revision 45980)
@@ -530,7 +530,9 @@
 		}
 
 		# Tags, if any.
-		$ret .= ' ' . ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions', &$classes );
+		list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
+		$classes = array_merge( $classes, $newClasses );
+		$ret .= " $tagSummary";
 
 		// Let extensions add data
 		wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
Index: branches/change-tagging/phase3/includes/PageHistory.php
===================================================================
--- branches/change-tagging/phase3/includes/PageHistory.php	(revision 45979)
+++ branches/change-tagging/phase3/includes/PageHistory.php	(revision 45980)
@@ -363,7 +363,9 @@
 		}
 
 		# Tags
-		$s .= ' ' . ChangeTags::formatSummaryRow( $row->ts_tags, 'history', &$classes );
+		list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
+		$classes = array_merge( $classes, $newClasses );
+		$s .= " $tagSummary";
 
 		wfRunHooks( 'PageHistoryLineEnding', array( $this, &$row , &$s ) );
 

Status & tagging log

Views
Toolbox