Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/55585


Change subject: Make sure no invalid (undo) helpful/unhelpful flags can be 
performed
......................................................................

Make sure no invalid (undo) helpful/unhelpful flags can be performed

Change-Id: I21edebbe0e292fefa1db850caea3b260d7de1499
---
M ArticleFeedbackv5.flagging.php
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleFeedbackv5 
refs/changes/85/55585/1

diff --git a/ArticleFeedbackv5.flagging.php b/ArticleFeedbackv5.flagging.php
index 576ec43..e793ed6 100644
--- a/ArticleFeedbackv5.flagging.php
+++ b/ArticleFeedbackv5.flagging.php
@@ -777,7 +777,7 @@
                $this->logId = $this->log( __FUNCTION__, 
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
 
                // was voted unhelpful already, now voting helpful should also 
remove unhelpful vote
-               if ( $toggle ) {
+               if ( $toggle && $this->feedback->aft_unhelpful > 0 ) {
                        $this->feedback->aft_unhelpful--;
                }
 
@@ -794,6 +794,11 @@
         * @return array|bool
         */
        public function undo_helpful( $notes, $toggle ) {
+               if ( $this->feedback->aft_helpful < 1 ) {
+                       $this->error = 
'articlefeedbackv5-invalid-feedback-state';
+                       return false;
+               }
+
                $this->feedback->aft_helpful--;
                $this->logId = $this->log( 'undo-helpful', 
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
 
@@ -814,7 +819,7 @@
                $this->logId = $this->log( __FUNCTION__, 
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
 
                // was voted helpful already, now voting unhelpful should also 
remove helpful vote
-               if ( $toggle ) {
+               if ( $toggle && $this->feedback->aft_helpful > 0 ) {
                        $this->feedback->aft_helpful--;
                }
 
@@ -831,6 +836,11 @@
         * @return array|bool
         */
        public function undo_unhelpful( $notes, $toggle ) {
+               if ( $this->feedback->aft_unhelpful < 1 ) {
+                       $this->error = 
'articlefeedbackv5-invalid-feedback-state';
+                       return false;
+               }
+
                $this->feedback->aft_unhelpful--;
                $this->logId = $this->log( 'undo-unhelpful', 
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/55585
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21edebbe0e292fefa1db850caea3b260d7de1499
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleFeedbackv5
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to