Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/189510
Change subject: Increase editcount for Flow contributions
......................................................................
Increase editcount for Flow contributions
Bug: T63887
Change-Id: I3dc45ca67c777f2b5616e732d0ebcffaed2d4189
---
M FlowActions.php
M autoload.php
M container.php
A includes/Data/Listener/EditCountListener.php
4 files changed, 61 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/10/189510/1
diff --git a/FlowActions.php b/FlowActions.php
index f8af072..906df8d 100644
--- a/FlowActions.php
+++ b/FlowActions.php
@@ -34,6 +34,7 @@
* * immediate: watchlist the title in the current process
* * rc_title: Either 'article' or 'owner' to select between
Workflow::getArticleTitle
* or Workflow::getOwnerTitle being used as the related recentchanges
entry on insert
+ * * editcount: True to increment user's edit count for this action
*/
$wgFlowActions = array(
'create-header' => array(
@@ -53,6 +54,7 @@
),
'class' => 'flow-history-create-header',
),
+ 'editcount' => true,
),
'edit-header' => array(
@@ -73,6 +75,7 @@
'class' => 'flow-history-edit-header',
),
'handler-class' => 'Flow\Actions\EditHeaderAction',
+ 'editcount' => true,
),
'create-topic-summary' => array(
@@ -97,6 +100,7 @@
),
'class' => 'flow-history-create-topic-summary',
),
+ 'editcount' => true,
),
'edit-topic-summary' => array(
@@ -122,6 +126,7 @@
'class' => 'flow-history-edit-topic-summary',
),
'handler-class' => 'Flow\Actions\EditTopicSummaryAction',
+ 'editcount' => true,
),
'edit-title' => array(
@@ -148,6 +153,7 @@
'watch' => array(
'immediate' => array(
'Flow\\Data\\Listener\\ImmediateWatchTopicListener', 'getCurrentUser' ),
),
+ 'editcount' => true,
),
// Normal posts are the 'reply' type.
@@ -175,6 +181,7 @@
'watch' => array(
'immediate' => array(
'Flow\\Data\\Listener\\ImmediateWatchTopicListener', 'getCurrentUser' ),
),
+ 'editcount' => true,
),
'edit-post' => array(
@@ -206,6 +213,7 @@
'watch' => array(
'immediate' => array(
'Flow\\Data\\Listener\\ImmediateWatchTopicListener', 'getCurrentUser' ),
),
+ 'editcount' => true,
),
'hide-post' => array(
@@ -548,6 +556,7 @@
'watch' => array(
'immediate' => array(
'Flow\\Data\\Listener\\ImmediateWatchTopicListener', 'getCurrentUser' ),
),
+ 'editcount' => true,
),
'history' => array(
diff --git a/autoload.php b/autoload.php
index c8e4451..1950c7f 100644
--- a/autoload.php
+++ b/autoload.php
@@ -81,6 +81,7 @@
'Flow\\Data\\LifecycleHandler' => __DIR__ .
'/includes/Data/LifecycleHandler.php',
'Flow\\Data\\Listener\\AbstractTopicInsertListener' => __DIR__ .
'/includes/Data/Listener/WatchTopicListener.php',
'Flow\\Data\\Listener\\DeferredInsertLifecycleHandler' => __DIR__ .
'/includes/Data/Listener/DeferredInsertLifecycleHandler.php',
+ 'Flow\\Data\\Listener\\EditCountListener' => __DIR__ .
'/includes/Data/Listener/EditCountListener.php',
'Flow\\Data\\Listener\\ImmediateWatchTopicListener' => __DIR__ .
'/includes/Data/Listener/WatchTopicListener.php',
'Flow\\Data\\Listener\\NotificationListener' => __DIR__ .
'/includes/Data/Listener/NotificationListener.php',
'Flow\\Data\\Listener\\OccupationListener' => __DIR__ .
'/includes/Data/Listener/OccupationListener.php',
diff --git a/container.php b/container.php
index e73c9e3..0ac7728 100644
--- a/container.php
+++ b/container.php
@@ -305,7 +305,8 @@
$c['reference.recorder'],
$c['storage.board_history.indexes.primary'],
$c['storage.header.listeners.username'],
- $c['listener.recentchanges']
+ $c['listener.recentchanges'],
+ $c['listener.editcount'],
);
} );
$c['storage.header.primary_key'] = array( 'rev_id' );
@@ -383,6 +384,7 @@
$c['listener.recentchanges'],
$c['storage.post_summary.listeners.username'],
$c['storage.board_history.indexes.primary'],
+ $c['listener.editcount'],
// topic history -- to keep a history by topic we have to know
what topic every post
// belongs to, not just its parent. TopicHistoryIndex is a
slight tweak to TopKIndex
// using TreeRepository for extra information and stuffing it
into topic_root while indexing
@@ -562,6 +564,7 @@
$c['storage.post.listeners.watch_topic'],
$c['storage.post.listeners.notification'],
$c['listener.recentchanges'],
+ $c['listener.editcount'],
// topic history -- to keep a history by topic we have to know
what topic every post
// belongs to, not just its parent. TopicHistoryIndex is a
slight tweak to TopKIndex
// using TreeRepository for extra information and stuffing it
into topic_root while indexing
@@ -1139,4 +1142,7 @@
);
} );
+$c['listener.editcount'] = $c->share( function( $c ) {
+ return new \Flow\Data\Listener\EditCountListener( $c['flow_actions'] );
+} );
return $c;
diff --git a/includes/Data/Listener/EditCountListener.php
b/includes/Data/Listener/EditCountListener.php
new file mode 100644
index 0000000..e7f40fe
--- /dev/null
+++ b/includes/Data/Listener/EditCountListener.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Flow\Data\Listener;
+
+use Flow\Data\LifecycleHandler;
+use Flow\Exception\InvalidDataException;
+use Flow\FlowActions;
+use Flow\Model\AbstractRevision;
+
+class EditCountListener implements LifecycleHandler {
+ /**
+ * @var FlowActions
+ */
+ protected $actions;
+
+ public function __construct( FlowActions $actions ) {
+ $this->actions = $actions;
+ }
+
+ public function onAfterLoad( $object, array $old ) {
+ // Nuthin
+ }
+
+ public function onAfterInsert( $revision, array $new, array $metadata )
{
+ if ( !$revision instanceof AbstractRevision ) {
+ throw new InvalidDataException( 'EditCountListener can
only attach to AbstractRevision storage');
+ }
+
+ $action = $revision->getChangeType();
+ $increase = $this->actions->getValue( $action, 'editcount' );
+
+ if ( $increase ) {
+ $revision->getUser()->incEditCount();
+ }
+ }
+
+ public function onAfterUpdate( $object, array $old, array $new, array
$metadata ) {
+ // Nuthin
+ }
+
+ public function onAfterRemove( $object, array $old, array $metadata ) {
+ // Nuthin
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/189510
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3dc45ca67c777f2b5616e732d0ebcffaed2d4189
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits