r109620 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109619‎ | r109620 | r109621 >
Date:15:46, 20 January 2012
Author:gregchiasson
Status:ok
Tags:aft 
Comment:
AFT5 - Follow up to r109565 - Add translation note, remove extraneous validation, and change the flag-count-update logic to work better on busy databases.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php
@@ -321,6 +321,7 @@
322322 'articlefeedbackv5-cta2-confirmation-title' => 'The title of the learn more CTA',
323323 'articlefeedbackv5-cta2-confirmation-call' => 'The explanatory text of the learn more CTA',
324324 'articlefeedbackv5-cta2-button-text' => 'The text for the button on the learn more CTA',
 325+ 'articlefeedbackv5-error-blocked' => 'This error message will be displayed on the form if the user is blocked from submitting feedback.',
325326 'articlefeedbackv5-error' => 'This error message will be displayed in a grey box replacing the form if there was an unrecoverable error.',
326327 'articlefeedbackv5-error-abuse' => 'This error message will be displayed above the form if the comment matched the spam or abuse filters. $1 is the link to the abuse policy.',
327328 'articlefeedbackv5-error-abuse-linktext' => 'The text for the abuse policy link.',
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
@@ -26,11 +26,6 @@
2727 $error = null;
2828 $dbr = wfGetDB( DB_SLAVE );
2929
30 - if ( !isset( $params['feedbackid'] )
31 - || !preg_match( '/^\d+$/', $params['feedbackid'] ) ) {
32 - $error = 'articlefeedbackv5-invalid-feedback-id';
33 - }
34 -
3530 # load feedback record, bail if we don't have one
3631 $record = $dbr->selectRow(
3732 'aft_article_feedback',
@@ -38,20 +33,16 @@
3934 array( 'af_id' => $params['feedbackid'] )
4035 );
4136
42 - # TODO:
 37+ $flags = array( 'abuse', 'hide', 'helpful', 'unhelpful', 'delete' );
4338 if ( !$record->af_id ) {
4439 // no-op, because this is already broken
4540 $error = 'articlefeedbackv5-invalid-feedback-id';
46 - } elseif ( $params['flagtype'] == 'abuse' ) {
47 - $update['af_abuse_count'] = $record->af_abuse_count + 1;
48 - } elseif ( $params['flagtype'] == 'hide' ) {
49 - $update['af_hide_count'] = $record->af_hide_count + 1;
50 - } elseif ( $params['flagtype'] == 'helpful' ) {
51 - $update['af_helpful_count'] = $record->af_helpful_count + 1;
52 - } elseif ( $params['flagtype'] == 'unhelpful' ) {
53 - $update['af_unhelpful_count'] = $record->af_unhelpful_count + 1;
54 - } elseif ( $params['flagtype'] == 'delete' ) {
55 - $update['af_delete_count'] = $record->af_delete_count + 1;
 41+ } elseif( in_array( $params['flagtype'], $flags ) ) {
 42+ // Probably this doesn't need validation, since the API
 43+ // will handle it, but if it's getting interpolated into
 44+ // the SQL, I'm really wary not re-validating it.
 45+ $flag = 'af_'.$params['flagtype'].'_count';
 46+ $update[] = "$flag = $flag + 1";
5647 } else {
5748 $error = 'articlefeedbackv5-invalid-feedback-flag';
5849 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109565AFT5 feedback page - allow sorting by helpfulness, and add unhelpful flag, pe...gregchiasson20:49, 19 January 2012

Status & tagging log