r61662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61661‎ | r61662 | r61663 >
Date:14:38, 29 January 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Reduce code duplication by having tables added in all code paths, by adding before if
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -91,14 +91,17 @@
9292 $this->dieUsage( 'patrol property is not available', 'patrol' );
9393 }
9494 }
 95+
 96+ $this->addFields( array (
 97+ 'rc_namespace',
 98+ 'rc_title',
 99+ 'rc_timestamp'
 100+ ) );
95101
96102 if ( is_null( $resultPageSet ) ) {
97103 $this->addFields( array (
98104 'rc_cur_id',
99 - 'rc_this_oldid',
100 - 'rc_namespace',
101 - 'rc_title',
102 - 'rc_timestamp'
 105+ 'rc_this_oldid'
103106 ) );
104107
105108 $this->addFieldsIf( 'rc_new', $this->fld_flags );
@@ -110,21 +113,10 @@
111114 $this->addFieldsIf( 'rc_patrolled', $this->fld_patrol );
112115 $this->addFieldsIf( 'rc_old_len', $this->fld_sizes );
113116 $this->addFieldsIf( 'rc_new_len', $this->fld_sizes );
114 - }
115 - elseif ( $params['allrev'] ) {
116 - $this->addFields( array (
117 - 'rc_this_oldid',
118 - 'rc_namespace',
119 - 'rc_title',
120 - 'rc_timestamp'
121 - ) );
 117+ } elseif ( $params['allrev'] ) {
 118+ $this->addFields( 'rc_this_oldid' );
122119 } else {
123 - $this->addFields( array (
124 - 'rc_cur_id',
125 - 'rc_namespace',
126 - 'rc_title',
127 - 'rc_timestamp'
128 - ) );
 120+ $this->addFields( 'rc_cur_id' );
129121 }
130122
131123 $this->addTables( array (

Comments

#Comment by Catrope (talk | contribs)   18:14, 29 January 2010
 			$this->addFields( array (
 				'rc_cur_id',
-				'rc_this_oldid',
-				'rc_namespace',
-				'rc_title',
-				'rc_timestamp'
+				'rc_this_oldid'
 			) );

This can be converted to a call without array()

#Comment by Reedy (talk | contribs)   18:27, 29 January 2010

There's 2 things in the array..?

#Comment by Catrope (talk | contribs)   18:30, 29 January 2010

Ignore me, I'm an idiot.

#Comment by Reedy (talk | contribs)   18:35, 29 January 2010
)

I was looking at the array and getting confused also. Some diff's don't make things obvious to the eye

Status & tagging log