r110430 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110429‎ | r110430 | r110431 >
Date:21:06, 31 January 2012
Author:gregchiasson
Status:ok
Tags:aft 
Comment:
AFT5: more instances of treating boolean flags like integers, and remove deleted/hidden feedback from lists unless specifically requested, rather than just hiding them based on permissions.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -246,14 +246,23 @@
247247
248248 // Don't let non-allowed users see these.
249249 if ( !$wgUser->isAllowed( 'aftv5-see-hidden-feedback' ) ) {
250 - $where['af_is_hidden'] = 0;
 250+ $where[] = 'af_is_hidden IS FALSE';
251251 }
252252
253253 // Don't let non-allowed users see these.
254254 if ( !$wgUser->isAllowed( 'aftv5-see-deleted-feedback' ) ) {
255 - $where['af_is_deleted'] = 0;
 255+ $where[] = 'af_is_deleted IS FALSE';
256256 }
257257
 258+ // Never show hidden or deleted posts unless specifically requested.
 259+ if( $filter != 'invisible' && $filter != 'deleted' ) {
 260+ $where[] = 'af_is_hidden IS FALSE';
 261+ }
 262+
 263+ if( $filter != 'deleted' ) {
 264+ $where[] = 'af_is_deleted IS FALSE';
 265+ }
 266+
258267 switch ( $filter ) {
259268 case 'needsoversight':
260269 $where[] = 'af_needs_oversight IS TRUE';
@@ -263,30 +272,31 @@
264273 $where['af_id'] = $filterValue;
265274 break;
266275 case 'visible':
267 - $where['af_is_deleted'] = 0;
268 - $where['af_is_hidden'] = 0;
 276+ $where[] = 'af_is_deleted IS FALSE';
 277+ $where[] = 'af_is_hidden IS FALSE';
269278 break;
270279 case 'invisible':
271 - $where[] = 'af_is_hidden > 0';
 280+ $where[] = 'af_is_hidden IS TRUE';
272281 break;
273282 case 'abusive':
274283 $where[] = 'af_abuse_count > 0';
275284 break;
276285 case 'helpful':
277 - $where[] = 'CONVERT(af_helpful_count, SIGNED) - CONVERT(af_unhelpful_count, SIGNED) > 0';
 286+ $where[] = 'af_net_helpfulness > 0';
278287 break;
279288 case 'unhelpful':
280 - $where[] = 'CONVERT(af_helpful_count, SIGNED) - CONVERT(af_unhelpful_count, SIGNED) < 0';
 289+ $where[] = 'af_net_helpfulness < 0';
281290 break;
282291 case 'comment':
283292 $where[] = 'comment.aa_response_text IS NOT NULL';
284293 break;
285294 case 'deleted':
286 - $where[] = 'af_is_deleted > 0';
 295+ $where[] = 'af_is_deleted IS TRUE';
287296 break;
288297 default:
289298 break;
290299 }
 300+
291301 return $where;
292302 }
293303

Status & tagging log