Index: trunk/phase3/includes/api/ApiQueryRecentChanges.php |
— | — | @@ -224,22 +224,14 @@ |
225 | 225 | } |
226 | 226 | |
227 | 227 | /* Add fields to our query if they are specified as a needed parameter. */ |
228 | | - $this->addFieldsIf( 'rc_id', $this->fld_ids ); |
229 | | - $this->addFieldsIf( 'rc_this_oldid', $this->fld_ids ); |
230 | | - $this->addFieldsIf( 'rc_last_oldid', $this->fld_ids ); |
| 228 | + $this->addFieldsIf( array( 'rc_id', 'rc_this_oldid', 'rc_last_oldid' ), $this->fld_ids ); |
231 | 229 | $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment ); |
232 | 230 | $this->addFieldsIf( 'rc_user', $this->fld_user ); |
233 | 231 | $this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid ); |
234 | | - $this->addFieldsIf( 'rc_minor', $this->fld_flags ); |
235 | | - $this->addFieldsIf( 'rc_bot', $this->fld_flags ); |
236 | | - $this->addFieldsIf( 'rc_new', $this->fld_flags ); |
237 | | - $this->addFieldsIf( 'rc_old_len', $this->fld_sizes ); |
238 | | - $this->addFieldsIf( 'rc_new_len', $this->fld_sizes ); |
| 232 | + $this->addFieldsIf( array( 'rc_minor', 'rc_new', 'rc_bot' ) , $this->fld_flags ); |
| 233 | + $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes ); |
239 | 234 | $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled ); |
240 | | - $this->addFieldsIf( 'rc_logid', $this->fld_loginfo ); |
241 | | - $this->addFieldsIf( 'rc_log_type', $this->fld_loginfo ); |
242 | | - $this->addFieldsIf( 'rc_log_action', $this->fld_loginfo ); |
243 | | - $this->addFieldsIf( 'rc_params', $this->fld_loginfo ); |
| 235 | + $this->addFieldsIf( array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ), $this->fld_loginfo ); |
244 | 236 | $showRedirects = $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] ); |
245 | 237 | } |
246 | 238 | |
Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php |
— | — | @@ -99,27 +99,14 @@ |
100 | 100 | $this->addWhere( 'ar_deleted = 0' ); |
101 | 101 | $this->addFields( array( 'ar_title', 'ar_namespace', 'ar_timestamp' ) ); |
102 | 102 | |
103 | | - if ( $fld_parentid ) { |
104 | | - $this->addFields( 'ar_parent_id' ); |
105 | | - } |
106 | | - if ( $fld_revid ) { |
107 | | - $this->addFields( 'ar_rev_id' ); |
108 | | - } |
109 | | - if ( $fld_user ) { |
110 | | - $this->addFields( 'ar_user_text' ); |
111 | | - } |
112 | | - if ( $fld_userid ) { |
113 | | - $this->addFields( 'ar_user' ); |
114 | | - } |
115 | | - if ( $fld_comment || $fld_parsedcomment ) { |
116 | | - $this->addFields( 'ar_comment' ); |
117 | | - } |
118 | | - if ( $fld_minor ) { |
119 | | - $this->addFields( 'ar_minor_edit' ); |
120 | | - } |
121 | | - if ( $fld_len ) { |
122 | | - $this->addFields( 'ar_len' ); |
123 | | - } |
| 103 | + $this->addFieldsIf( 'ar_parent_id', $fld_parentid ); |
| 104 | + $this->addFieldsIf( 'ar_rev_id', $fld_revid ); |
| 105 | + $this->addFieldsIf( 'ar_user_text', $fld_user ); |
| 106 | + $this->addFieldsIf( 'ar_user', $fld_userid ); |
| 107 | + $this->addFieldsIf( 'ar_comment', $fld_comment || $fld_parsedcomment ); |
| 108 | + $this->addFieldsIf( 'ar_minor_edit', $fld_minor ); |
| 109 | + $this->addFieldsIf( 'ar_len', $fld_len ); |
| 110 | + |
124 | 111 | if ( $fld_content ) { |
125 | 112 | $this->addTables( 'text' ); |
126 | 113 | $this->addFields( array( 'ar_text', 'ar_text_id', 'old_text', 'old_flags' ) ); |
Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | |
113 | 113 | /** |
114 | 114 | * Add a set of fields to select to the internal array |
115 | | - * @param $value mixed Field name or array of field names |
| 115 | + * @param $value array|string Field name or array of field names |
116 | 116 | */ |
117 | 117 | protected function addFields( $value ) { |
118 | 118 | if ( is_array( $value ) ) { |
— | — | @@ -123,7 +123,7 @@ |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Same as addFields(), but add the fields only if a condition is met |
127 | | - * @param $value mixed See addFields() |
| 127 | + * @param $value array|string See addFields() |
128 | 128 | * @param $condition bool If false, do nothing |
129 | 129 | * @return bool $condition |
130 | 130 | */ |
Index: trunk/phase3/includes/api/ApiQueryBlocks.php |
— | — | @@ -70,33 +70,17 @@ |
71 | 71 | $this->addTables( 'ipblocks' ); |
72 | 72 | $this->addFields( 'ipb_auto' ); |
73 | 73 | |
74 | | - if ( $fld_id ) { |
75 | | - $this->addFields( 'ipb_id' ); |
76 | | - } |
77 | | - if ( $fld_user || $fld_userid ) { |
78 | | - $this->addFields( array( 'ipb_address', 'ipb_user' ) ); |
79 | | - } |
80 | | - if ( $fld_by ) { |
81 | | - $this->addFields( 'ipb_by_text' ); |
82 | | - } |
83 | | - if ( $fld_byid ) { |
84 | | - $this->addFields( 'ipb_by' ); |
85 | | - } |
86 | | - if ( $fld_timestamp ) { |
87 | | - $this->addFields( 'ipb_timestamp' ); |
88 | | - } |
89 | | - if ( $fld_expiry ) { |
90 | | - $this->addFields( 'ipb_expiry' ); |
91 | | - } |
92 | | - if ( $fld_reason ) { |
93 | | - $this->addFields( 'ipb_reason' ); |
94 | | - } |
95 | | - if ( $fld_range ) { |
96 | | - $this->addFields( array( 'ipb_range_start', 'ipb_range_end' ) ); |
97 | | - } |
98 | | - if ( $fld_flags ) { |
99 | | - $this->addFields( array( 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock', 'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ) ); |
100 | | - } |
| 74 | + $this->addFieldsIf ( 'ipb_id', $fld_id ); |
| 75 | + $this->addFieldsIf( array( 'ipb_address', 'ipb_user' ), $fld_user || $fld_userid ); |
| 76 | + $this->addFieldsIf( 'ipb_by_text', $fld_by ); |
| 77 | + $this->addFieldsIf( 'ipb_by', $fld_byid ); |
| 78 | + $this->addFieldsIf( 'ipb_timestamp', $fld_timestamp ); |
| 79 | + $this->addFieldsIf( 'ipb_expiry', $fld_expiry ); |
| 80 | + $this->addFieldsIf( 'ipb_reason', $fld_reason ); |
| 81 | + $this->addFieldsIf( array( 'ipb_range_start', 'ipb_range_end' ), $fld_range ); |
| 82 | + $this->addFieldsIf( array( 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock', |
| 83 | + 'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ), |
| 84 | + $fld_flags ); |
101 | 85 | |
102 | 86 | $this->addOption( 'LIMIT', $params['limit'] + 1 ); |
103 | 87 | $this->addWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] ); |
Index: trunk/phase3/includes/api/ApiQueryFilearchive.php |
— | — | @@ -69,21 +69,10 @@ |
70 | 70 | $this->addFields( array( 'fa_name', 'fa_deleted' ) ); |
71 | 71 | $this->addFieldsIf( 'fa_storage_key', $fld_sha1 ); |
72 | 72 | $this->addFieldsIf( 'fa_timestamp', $fld_timestamp ); |
73 | | - |
74 | | - if ( $fld_user ) { |
75 | | - $this->addFields( array( 'fa_user', 'fa_user_text' ) ); |
76 | | - } |
77 | | - |
78 | | - if ( $fld_dimensions || $fld_size ) { |
79 | | - $this->addFields( array( 'fa_height', 'fa_width', 'fa_size' ) ); |
80 | | - } |
81 | | - |
| 73 | + $this->addFieldsIf( array( 'fa_user', 'fa_user_text' ), $fld_user ); |
| 74 | + $this->addFieldsIf( array( 'fa_height', 'fa_width', 'fa_size' ), $fld_dimensions || $fld_size ); |
82 | 75 | $this->addFieldsIf( 'fa_description', $fld_description ); |
83 | | - |
84 | | - if ( $fld_mime ) { |
85 | | - $this->addFields( array( 'fa_major_mime', 'fa_minor_mime' ) ); |
86 | | - } |
87 | | - |
| 76 | + $this->addFieldsIf( array( 'fa_major_mime', 'fa_minor_mime' ), $fld_mime ); |
88 | 77 | $this->addFieldsIf( 'fa_metadata', $fld_metadata ); |
89 | 78 | $this->addFieldsIf( 'fa_bits', $fld_bitdepth ); |
90 | 79 | |
Index: trunk/phase3/includes/api/ApiQueryLogEvents.php |
— | — | @@ -86,13 +86,10 @@ |
87 | 87 | 'log_deleted', |
88 | 88 | ) ); |
89 | 89 | |
90 | | - $this->addFieldsIf( 'log_id', $this->fld_ids ); |
91 | | - $this->addFieldsIf( 'page_id', $this->fld_ids ); |
92 | | - $this->addFieldsIf( 'log_user', $this->fld_user ); |
93 | | - $this->addFieldsIf( 'user_name', $this->fld_user ); |
| 90 | + $this->addFieldsIf( array( 'log_id', 'page_id' ), $this->fld_ids ); |
| 91 | + $this->addFieldsIf( array( 'log_user', 'user_name' ), $this->fld_user ); |
94 | 92 | $this->addFieldsIf( 'user_id', $this->fld_userid ); |
95 | | - $this->addFieldsIf( 'log_namespace', $this->fld_title || $this->fld_parsedcomment ); |
96 | | - $this->addFieldsIf( 'log_title', $this->fld_title || $this->fld_parsedcomment ); |
| 93 | + $this->addFieldsIf( array( 'log_namespace', 'log_title' ), $this->fld_title || $this->fld_parsedcomment ); |
97 | 94 | $this->addFieldsIf( 'log_comment', $this->fld_comment || $this->fld_parsedcomment ); |
98 | 95 | $this->addFieldsIf( 'log_params', $this->fld_details ); |
99 | 96 | |
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php |
— | — | @@ -101,20 +101,14 @@ |
102 | 102 | 'rc_last_oldid', |
103 | 103 | ) ); |
104 | 104 | |
105 | | - $this->addFieldsIf( 'rc_new', $this->fld_flags ); |
106 | | - $this->addFieldsIf( 'rc_minor', $this->fld_flags ); |
107 | | - $this->addFieldsIf( 'rc_bot', $this->fld_flags ); |
| 105 | + $this->addFieldsIf( array( 'rc_new', 'rc_minor', 'rc_bot' ), $this->fld_flags ); |
108 | 106 | $this->addFieldsIf( 'rc_user', $this->fld_user || $this->fld_userid ); |
109 | 107 | $this->addFieldsIf( 'rc_user_text', $this->fld_user ); |
110 | 108 | $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment ); |
111 | 109 | $this->addFieldsIf( 'rc_patrolled', $this->fld_patrol ); |
112 | | - $this->addFieldsIf( 'rc_old_len', $this->fld_sizes ); |
113 | | - $this->addFieldsIf( 'rc_new_len', $this->fld_sizes ); |
| 110 | + $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes ); |
114 | 111 | $this->addFieldsIf( 'wl_notificationtimestamp', $this->fld_notificationtimestamp ); |
115 | | - $this->addFieldsIf( 'rc_logid', $this->fld_loginfo ); |
116 | | - $this->addFieldsIf( 'rc_log_type', $this->fld_loginfo ); |
117 | | - $this->addFieldsIf( 'rc_log_action', $this->fld_loginfo ); |
118 | | - $this->addFieldsIf( 'rc_params', $this->fld_loginfo ); |
| 112 | + $this->addFieldsIf( array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ), $this->fld_loginfo ); |
119 | 113 | } elseif ( $params['allrev'] ) { |
120 | 114 | $this->addFields( 'rc_this_oldid' ); |
121 | 115 | } else { |
Index: trunk/phase3/includes/api/ApiQueryTags.php |
— | — | @@ -64,9 +64,7 @@ |
65 | 65 | $this->addTables( 'change_tag' ); |
66 | 66 | $this->addFields( 'ct_tag' ); |
67 | 67 | |
68 | | - if ( $this->fld_hitcount ) { |
69 | | - $this->addFields( 'count(*) AS hitcount' ); |
70 | | - } |
| 68 | + $this->addFieldsIf( 'count(*) AS hitcount', $this->fld_hitcount ); |
71 | 69 | |
72 | 70 | $this->addOption( 'LIMIT', $this->limit + 1 ); |
73 | 71 | $this->addOption( 'GROUP BY', 'ct_tag' ); |
Index: trunk/phase3/includes/api/ApiQueryUserContributions.php |
— | — | @@ -249,8 +249,7 @@ |
250 | 250 | // $this->addFieldsIf( 'rev_text_id', $this->fld_ids ); // Should this field be exposed? |
251 | 251 | $this->addFieldsIf( 'rev_comment', $this->fld_comment || $this->fld_parsedcomment ); |
252 | 252 | $this->addFieldsIf( 'rev_len', $this->fld_size ); |
253 | | - $this->addFieldsIf( 'rev_minor_edit', $this->fld_flags ); |
254 | | - $this->addFieldsIf( 'rev_parent_id', $this->fld_flags ); |
| 253 | + $this->addFieldsIf( array( 'rev_minor_edit', 'rev_parent_id' ), $this->fld_flags ); |
255 | 254 | $this->addFieldsIf( 'rc_patrolled', $this->fld_patrolled ); |
256 | 255 | |
257 | 256 | if ( $this->fld_tags ) { |