Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/54426
Change subject: General cleanup/fixes
......................................................................
General cleanup/fixes
* Fix unittests
* logging table is not available, so make sure it isn't called
* don't query cluster for data; unittests assume local $this->db
* Fix data merge script
* add archive action (although previously non-existant)
* i18n log_title
* Fix cache purge script
* incorrect cache key name was used; use dedicated method instead
* Cleanup flagger
* route all log calls to new ->log() function (instead of calling other
class directly, multiple times)
Change-Id: I6254fbcc8a1579d797974a934da6b787df949400
---
M ArticleFeedbackv5.flagging.php
M ArticleFeedbackv5.model.php
M data/maintenance/DataModelPurgeCache.php
M maintenance/legacyToShard.php
M tests/ArticleFeedbackv5ModelTest.php
5 files changed, 215 insertions(+), 159 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticleFeedbackv5
refs/changes/26/54426/1
diff --git a/ArticleFeedbackv5.flagging.php b/ArticleFeedbackv5.flagging.php
index 8d76668..576ec43 100644
--- a/ArticleFeedbackv5.flagging.php
+++ b/ArticleFeedbackv5.flagging.php
@@ -63,7 +63,7 @@
*
* @var int
*/
- private $logId = null;
+ private $logId;
/**
* Constructor
@@ -150,6 +150,25 @@
}
/**
+ * Log the performed action
+ *
+ * @param string $action
+ * @param int $pageId
+ * @param mixed $feedbackId
+ * @param string $comment
+ * @param User $user
+ * @return int
+ */
+ protected function log( $action, $pageId, $feedbackId, $comment, User
$user ) {
+ $params = array();
+ if ( $this->source ) {
+ $params['source'] = $this->source;
+ }
+
+ return ArticleFeedbackv5Activity::log( $action, $pageId,
$feedbackId, $comment, $user, $params );
+ }
+
+ /**
* Flag: request oversight
*
* This flag allows monitors (who can hide feedback but not delete it)
to
@@ -159,7 +178,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function request( $notes, $toggle ) {
+ public function request( $notes, $toggle ) {
// already requested?
if ( $this->feedback->isRequested() ) {
$this->error =
'articlefeedbackv5-invalid-feedback-state';
@@ -168,7 +187,7 @@
$this->feedback->aft_request = 1;
$this->feedback->aft_decline = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
// autohide if not yet hidden
if ( !$this->feedback->isHidden() ) {
@@ -178,7 +197,7 @@
*/
$this->feedback->aft_hide = 1;
$this->feedback->aft_autohide = 1;
- ArticleFeedbackv5Activity::log( 'autohide',
$this->feedback->aft_page, $this->feedback->aft_id, 'Automatic hide',
$this->user, array( 'source' => $this->source ) );
+ $this->log( 'autohide', $this->feedback->aft_page,
$this->feedback->aft_id, 'Automatic hide', $this->user );
}
// send an email to oversighter(s)
@@ -194,7 +213,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function unrequest( $notes, $toggle ) {
+ public function unrequest( $notes, $toggle ) {
// not yet requested?
if ( !$this->feedback->isRequested() ) {
$this->error =
'articlefeedbackv5-invalid-feedback-state';
@@ -202,13 +221,13 @@
}
$this->feedback->aft_request = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
// un-hide if autohidden
if ( $this->feedback->aft_hide && $this->feedback->aft_autohide
) {
$this->feedback->aft_hide = 0;
$this->feedback->aft_autohide = 0;
- ArticleFeedbackv5Activity::log( 'unhide',
$this->feedback->aft_page, $this->feedback->aft_id, 'Automatic un-hide',
$this->user, array( 'source' => $this->source ) );
+ $this->log( 'unhide', $this->feedback->aft_page,
$this->feedback->aft_id, 'Automatic un-hide', $this->user );
}
return true;
@@ -224,7 +243,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function decline( $notes, $toggle ) {
+ public function decline( $notes, $toggle ) {
// not requested?
if ( !$this->feedback->isRequested() ) {
$this->error =
'articlefeedbackv5-invalid-feedback-state';
@@ -232,13 +251,13 @@
}
$this->feedback->aft_decline = 1;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
// un-hide if autohidden
if ( $this->feedback->aft_hide && $this->feedback->aft_autohide
) {
$this->feedback->aft_hide = 0;
$this->feedback->aft_autohide = 0;
- ArticleFeedbackv5Activity::log( 'unhide',
$this->feedback->aft_page, $this->feedback->aft_id, 'Automatic un-hide',
$this->user, array( 'source' => $this->source ) );
+ $this->log( 'unhide', $this->feedback->aft_page,
$this->feedback->aft_id, 'Automatic un-hide', $this->user );
}
return true;
@@ -254,7 +273,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function feature( $notes, $toggle ) {
+ public function feature( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -276,7 +295,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
// clear all abuse flags
if ( $this->feedback->aft_flag && $this->feedback->aft_autoflag
) {
@@ -293,7 +312,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function unfeature( $notes, $toggle ) {
+ public function unfeature( $notes, $toggle ) {
if (
!$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -315,7 +334,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -330,7 +349,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function resolve( $notes, $toggle ) {
+ public function resolve( $notes, $toggle ) {
if (
// $this->feedback->isFeatured() || // can go straight
from featured to resolved
$this->feedback->isResolved() ||
@@ -352,7 +371,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -364,7 +383,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function unresolve( $notes, $toggle ) {
+ public function unresolve( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
!$this->feedback->isResolved() ||
@@ -386,7 +405,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -400,7 +419,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function noaction( $notes, $toggle ) {
+ public function noaction( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -422,7 +441,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -434,7 +453,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function unnoaction( $notes, $toggle ) {
+ public function unnoaction( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -456,19 +475,19 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
/**
- * Flag: mark a post as nappropriate
+ * Flag: mark a post as inappropriate
*
* @param $notes string any notes passed in
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function inappropriate( $notes, $toggle ) {
+ public function inappropriate( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -490,7 +509,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -502,7 +521,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function uninappropriate( $notes, $toggle ) {
+ public function uninappropriate( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -524,7 +543,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -536,7 +555,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function hide( $notes, $toggle ) {
+ public function hide( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -558,7 +577,7 @@
$this->feedback->aft_hide = 1;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -570,7 +589,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function unhide( $notes, $toggle ) {
+ public function unhide( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -594,7 +613,7 @@
$this->feedback->aft_autohide = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
// clear all abuse flags
if ( $this->feedback->aft_flag && $this->feedback->aft_autoflag
) {
@@ -611,7 +630,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function archive( $notes, $toggle ) {
+ public function archive( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -633,7 +652,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -645,7 +664,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function unarchive( $notes, $toggle ) {
+ public function unarchive( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -667,7 +686,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -679,7 +698,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function oversight( $notes, $toggle ) {
+ public function oversight( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -703,7 +722,7 @@
$this->feedback->aft_hide = 0;
$this->feedback->aft_oversight = 1;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -715,7 +734,7 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function unoversight( $notes, $toggle ) {
+ public function unoversight( $notes, $toggle ) {
if (
$this->feedback->isFeatured() ||
$this->feedback->isResolved() ||
@@ -739,87 +758,7 @@
$this->feedback->aft_request = 0;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
-
- return true;
- }
-
- /**
- * Flag: flag as abuse
- *
- * This flag allows readers to flag a piece of feedback as abusive.
- *
- * @param $notes string any notes passed in
- * @param $toggle bool whether to toggle the flag
- * @return array|bool
- */
- private function flag( $notes, $toggle ) {
- $flag = $this->isSystemCall() ? 'autoflag' : 'flag';
- $this->feedback->{"aft_$flag"}++;
- $this->logId = ArticleFeedbackv5Activity::log( $flag,
$this->feedback->aft_page, $this->feedback->aft_id, $notes,
$this->isSystemCall() ? null : $this->user, array( 'source' => $this->source )
);
-
- global $wgArticleFeedbackv5HideAbuseThreshold;
-
- // auto-hide after [threshold] flags
- if ( $this->feedback->aft_flag + $this->feedback->aft_autoflag
> $wgArticleFeedbackv5HideAbuseThreshold &&
- !$this->feedback->isHidden() ) {
- /*
- * We want to keep track of hides/unhides, but also
autohides.
- * Feedback will be hidden when hide + autohide > unhide
- */
- $this->feedback->aft_hide = 1;
- $this->feedback->aft_autohide = 1;
- ArticleFeedbackv5Activity::log( 'autohide',
$this->feedback->aft_page, $this->feedback->aft_id, 'Automatic hide',
$this->user, array( 'source' => $this->source ) );
- }
-
- return true;
- }
-
- /**
- * Flag: flag as abuse
- *
- * This flag allows readers to remove an abuse flag on a piece of
feedback.
- *
- * @param $notes string any notes passed in
- * @param $toggle bool whether to toggle the flag
- * @return array|bool
- */
- private function unflag( $notes, $toggle ) {
- if ( $this->feedback->aft_flag <= 0 ) {
- $this->feedback->aft_autoflag = 0;
- } else {
- $this->feedback->aft_flag--;
- }
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
-
- global $wgArticleFeedbackv5HideAbuseThreshold;
-
- // un-hide if autohidden & we don't have [threshold] flags
anymore
- if ( $this->feedback->aft_flag + $this->feedback->aft_autoflag
< $wgArticleFeedbackv5HideAbuseThreshold &&
- $this->feedback->aft_autohide ) {
- $this->feedback->aft_autohide = 0;
- ArticleFeedbackv5Activity::log( 'unhide',
$this->feedback->aft_page, $this->feedback->aft_id, 'Automatic un-hide',
$this->user, array( 'source' => $this->source ) );
- }
-
- return true;
- }
-
- /**
- * Flag: clear all abuse flags
- *
- * @param $notes string any notes passed in
- * @param $toggle bool whether to toggle the flag
- * @return array|bool
- */
- private function clear_flags( $notes, $toggle ) {
- $this->feedback->aft_autoflag = 0;
- $this->feedback->aft_flag = 0;
-
- /*
- * Note: this one does not save logId because (currently) it
will never
- * be called directly, but only as an automated result after
certain flags.
- */
- ArticleFeedbackv5Activity::log( 'clear-flags',
$this->feedback->aft_page, $this->feedback->aft_id, 'Automatically clearing all
flags', $this->user, array( 'source' => $this->source ) );
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -833,9 +772,9 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function helpful( $notes, $toggle ) {
+ public function helpful( $notes, $toggle ) {
$this->feedback->aft_helpful++;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $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 ) {
@@ -854,9 +793,9 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function undo_helpful( $notes, $toggle ) {
+ public function undo_helpful( $notes, $toggle ) {
$this->feedback->aft_helpful--;
- $this->logId = ArticleFeedbackv5Activity::log( 'undo-helpful',
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $this->logId = $this->log( 'undo-helpful',
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
return true;
}
@@ -870,9 +809,9 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function unhelpful( $notes, $toggle ) {
+ public function unhelpful( $notes, $toggle ) {
$this->feedback->aft_unhelpful++;
- $this->logId = ArticleFeedbackv5Activity::log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user, array(
'source' => $this->source ) );
+ $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 ) {
@@ -891,9 +830,89 @@
* @param $toggle bool whether to toggle the flag
* @return array|bool
*/
- private function undo_unhelpful( $notes, $toggle ) {
+ public function undo_unhelpful( $notes, $toggle ) {
$this->feedback->aft_unhelpful--;
- $this->logId = ArticleFeedbackv5Activity::log(
'undo-unhelpful', $this->feedback->aft_page, $this->feedback->aft_id, $notes,
$this->user, array( 'source' => $this->source ) );
+ $this->logId = $this->log( 'undo-unhelpful',
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
+
+ return true;
+ }
+
+ /**
+ * Flag: flag as abuse
+ *
+ * This flag allows readers to flag a piece of feedback as abusive.
+ *
+ * @param $notes string any notes passed in
+ * @param $toggle bool whether to toggle the flag
+ * @return array|bool
+ */
+ public function flag( $notes, $toggle ) {
+ $flag = $this->isSystemCall() ? 'autoflag' : 'flag';
+ $this->feedback->{"aft_$flag"}++;
+ $this->logId = $this->log( $flag, $this->feedback->aft_page,
$this->feedback->aft_id, $notes, $this->isSystemCall() ? null : $this->user );
+
+ global $wgArticleFeedbackv5HideAbuseThreshold;
+
+ // auto-hide after [threshold] flags
+ if ( $this->feedback->aft_flag + $this->feedback->aft_autoflag
> $wgArticleFeedbackv5HideAbuseThreshold &&
+ !$this->feedback->isHidden() ) {
+ /*
+ * We want to keep track of hides/unhides, but also
autohides.
+ * Feedback will be hidden when hide + autohide > unhide
+ */
+ $this->feedback->aft_hide = 1;
+ $this->feedback->aft_autohide = 1;
+ $this->log( 'autohide', $this->feedback->aft_page,
$this->feedback->aft_id, 'Automatic hide', $this->user );
+ }
+
+ return true;
+ }
+
+ /**
+ * Flag: flag as abuse
+ *
+ * This flag allows readers to remove an abuse flag on a piece of
feedback.
+ *
+ * @param $notes string any notes passed in
+ * @param $toggle bool whether to toggle the flag
+ * @return array|bool
+ */
+ public function unflag( $notes, $toggle ) {
+ if ( $this->feedback->aft_flag <= 0 ) {
+ $this->feedback->aft_autoflag = 0;
+ } else {
+ $this->feedback->aft_flag--;
+ }
+ $this->logId = $this->log( __FUNCTION__,
$this->feedback->aft_page, $this->feedback->aft_id, $notes, $this->user );
+
+ global $wgArticleFeedbackv5HideAbuseThreshold;
+
+ // un-hide if autohidden & we don't have [threshold] flags
anymore
+ if ( $this->feedback->aft_flag + $this->feedback->aft_autoflag
< $wgArticleFeedbackv5HideAbuseThreshold &&
+ $this->feedback->aft_autohide ) {
+ $this->feedback->aft_autohide = 0;
+ $this->log( 'unhide', $this->feedback->aft_page,
$this->feedback->aft_id, 'Automatic un-hide', $this->user );
+ }
+
+ return true;
+ }
+
+ /**
+ * Flag: clear all abuse flags
+ *
+ * @param $notes string any notes passed in
+ * @param $toggle bool whether to toggle the flag
+ * @return array|bool
+ */
+ protected function clear_flags( $notes, $toggle ) {
+ $this->feedback->aft_autoflag = 0;
+ $this->feedback->aft_flag = 0;
+
+ /*
+ * Note: this one does not save logId because (currently) it
will never
+ * be called directly, but only as an automated result after
certain flags.
+ */
+ $this->log( 'clear-flags', $this->feedback->aft_page,
$this->feedback->aft_id, 'Automatically clearing all flags', $this->user );
return true;
}
diff --git a/ArticleFeedbackv5.model.php b/ArticleFeedbackv5.model.php
index 1fd5289..ea8ce42 100644
--- a/ArticleFeedbackv5.model.php
+++ b/ArticleFeedbackv5.model.php
@@ -513,6 +513,11 @@
public static function preload( array $entries ) {
parent::preload( $entries );
+ // when running unittests, ignore this
+ if ( defined( 'MW_PHPUNIT_TEST' ) && MW_PHPUNIT_TEST ) {
+ return;
+ }
+
/*
* Only editors will have the detailed toolbox, so only for
editors,
* we'll need to know the details of the last editor activity.
diff --git a/data/maintenance/DataModelPurgeCache.php
b/data/maintenance/DataModelPurgeCache.php
index a549bdd..a84cad0 100644
--- a/data/maintenance/DataModelPurgeCache.php
+++ b/data/maintenance/DataModelPurgeCache.php
@@ -99,8 +99,7 @@
foreach ( $class::$lists as $list => $properties ) {
// clear lists
- $key = wfMemcKey( get_called_class(),
'getListValidity', $list, $shard );
- $class::getCache()->delete( $key );
+ $class::uncacheList( $list, $shard );
// clear counts
$key = wfMemcKey( $class, 'getCount', $list, $shard );
diff --git a/maintenance/legacyToShard.php b/maintenance/legacyToShard.php
index a273ad8..c45927b 100644
--- a/maintenance/legacyToShard.php
+++ b/maintenance/legacyToShard.php
@@ -181,15 +181,14 @@
array( 'log_action' ),
array(
'log_type' => array(
'articlefeedbackv5', 'suppress' ),
- 'log_action' => array(
- 'oversight', 'unoversight',
'decline', 'request', 'unrequest',
- 'hidden', 'hide', 'unhidden',
'unhide', 'flag', 'unflag', 'autoflag', 'autohide',
- 'feature', 'unfeature',
'resolve', 'unresolve', 'helpful',
- 'unhelpful', 'undo-helpful',
'undo-unhelpful', 'clear-flags'
- ),
+ 'log_action' =>
+ array_merge(
+ array_keys(
ArticleFeedbackv5Activity::$actions ),
+ array( 'hidden',
'unhidden' ) // deprecated but may still have entries
+ ),
'log_namespace' => NS_SPECIAL,
'log_page' => 0,
- 'log_title' =>
"ArticleFeedbackv5/$row->page_title/$row->af_id"
+ 'log_title' =>
SpecialPage::getTitleFor( 'ArticleFeedbackv5', "$row->page_title/$row->af_id"
)->getDBkey()
),
__METHOD__,
array(
@@ -199,13 +198,6 @@
foreach ( $logging as $log ) {
switch ( $log->log_action ) {
- case 'decline':
- $feedback->aft_decline = 1;
- if ( $feedback->aft_hide &&
$feedback->aft_autohide ) {
- $feedback->aft_hide = 0;
- $feedback->aft_autohide
= 0;
- }
- break;
case 'request':
$feedback->aft_request = 1;
$feedback->aft_decline = 0;
@@ -221,21 +213,10 @@
$feedback->aft_autohide
= 0;
}
break;
- case 'flag':
- case 'autoflag':
-
$feedback->{"aft_$log->log_action"}++;
- if ( $feedback->aft_flag +
$feedback->aft_autoflag > $wgArticleFeedbackv5HideAbuseThreshold &&
!$feedback->isHidden() ) {
- $feedback->aft_hide = 1;
- $feedback->aft_autohide
= 1;
- }
- break;
- case 'unflag':
- if ( $feedback->aft_flag <= 0 )
{
- $feedback->aft_autoflag
= 0;
- } else {
- $feedback->aft_flag--;
- }
- if ( $feedback->aft_flag +
$feedback->aft_autoflag < $wgArticleFeedbackv5HideAbuseThreshold &&
$feedback->aft_autohide ) {
+ case 'decline':
+ $feedback->aft_decline = 1;
+ if ( $feedback->aft_hide &&
$feedback->aft_autohide ) {
+ $feedback->aft_hide = 0;
$feedback->aft_autohide
= 0;
}
break;
@@ -244,6 +225,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
@@ -257,6 +239,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
break;
@@ -265,6 +248,7 @@
$feedback->aft_resolve = 1;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
break;
@@ -273,6 +257,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
break;
@@ -281,6 +266,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 1;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
break;
@@ -289,6 +275,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
break;
@@ -297,6 +284,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
1;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
break;
@@ -305,6 +293,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
break;
@@ -314,6 +303,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 1;
$feedback->aft_oversight = 0;
break;
@@ -322,6 +312,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 1;
$feedback->aft_oversight = 0;
@@ -333,6 +324,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
@@ -342,11 +334,30 @@
$feedback->aft_flag = 0;
}
break;
+ case 'inappropriate':
+ $feedback->aft_feature = 0;
+ $feedback->aft_resolve = 0;
+ $feedback->aft_noaction = 0;
+ $feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 1;
+ $feedback->aft_hide = 0;
+ $feedback->aft_oversight = 0;
+ break;
+ case 'uninappropriate':
+ $feedback->aft_feature = 0;
+ $feedback->aft_resolve = 0;
+ $feedback->aft_noaction = 0;
+ $feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
+ $feedback->aft_hide = 0;
+ $feedback->aft_oversight = 0;
+ break;
case 'oversight':
$feedback->aft_feature = 0;
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 1;
@@ -361,6 +372,7 @@
$feedback->aft_resolve = 0;
$feedback->aft_noaction = 0;
$feedback->aft_inappropriate =
0;
+ $feedback->aft_archive = 0;
$feedback->aft_hide = 0;
$feedback->aft_oversight = 0;
@@ -382,6 +394,24 @@
case 'undo-unhelpful':
$feedback->aft_unhelpful--;
break;
+ case 'flag':
+ case 'autoflag':
+
$feedback->{"aft_$log->log_action"}++;
+ if ( $feedback->aft_flag +
$feedback->aft_autoflag > $wgArticleFeedbackv5HideAbuseThreshold &&
!$feedback->isHidden() ) {
+ $feedback->aft_hide = 1;
+ $feedback->aft_autohide
= 1;
+ }
+ break;
+ case 'unflag':
+ if ( $feedback->aft_flag <= 0 )
{
+ $feedback->aft_autoflag
= 0;
+ } else {
+ $feedback->aft_flag--;
+ }
+ if ( $feedback->aft_flag +
$feedback->aft_autoflag < $wgArticleFeedbackv5HideAbuseThreshold &&
$feedback->aft_autohide ) {
+ $feedback->aft_autohide
= 0;
+ }
+ break;
case 'clear-flags':
$feedback->aft_autoflag = 0;
$feedback->aft_flag = 0;
diff --git a/tests/ArticleFeedbackv5ModelTest.php
b/tests/ArticleFeedbackv5ModelTest.php
index b4b2046..f5ec7bc 100644
--- a/tests/ArticleFeedbackv5ModelTest.php
+++ b/tests/ArticleFeedbackv5ModelTest.php
@@ -12,11 +12,12 @@
public function setUp() {
parent::setUp();
+ global $wgMemc, $wgArticleFeedbackv5Cluster;
+
// init some volatile BagOStuff
$this->setMwGlobals( array(
'wgMemc' => new HashBagOStuff,
) );
- global $wgMemc;
ArticleFeedbackv5Model::setCache( $wgMemc );
// setup db tables
@@ -24,6 +25,8 @@
$this->db->dropTable( 'aft_feedback' );
$this->db->sourceFile( __DIR__ .
'/../sql/ArticleFeedbackv5.sql' );
$this->db->commit();
+ // don't connect to external cluster but use main db, that has
been prepared for unittests ($this->db)
+ $wgArticleFeedbackv5Cluster = false;
// init sample object
$this->sample = new ArticleFeedbackv5Model();
--
To view, visit https://gerrit.wikimedia.org/r/54426
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6254fbcc8a1579d797974a934da6b787df949400
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticleFeedbackv5
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits