Merge "Add block notice stats on EditPage."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 28 Nov 2018 19:55:12 +0000 (19:55 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 28 Nov 2018 19:55:12 +0000 (19:55 +0000)
includes/DefaultSettings.php
includes/EditPage.php

index 5175543..44c5364 100644 (file)
@@ -9054,6 +9054,16 @@ $wgChangeTagsSchemaMigrationStage = MIGRATION_NEW;
  */
 $wgEnablePartialBlocks = false;
 
+/**
+ * Enable stats monitoring when Block Notices are displayed in different places around core
+ * and extensions.
+ *
+ * @since 1.34
+ * @deprecated 1.34
+ * @var bool
+ */
+$wgEnableBlockNoticeStats = false;
+
 /**
  * For really cool vim folding this needs to be at the end:
  * vim: foldmarker=@{,@} foldmethod=marker
index 5f4c3ae..9e278af 100644 (file)
@@ -627,14 +627,23 @@ class EditPage {
                if ( $permErrors ) {
                        wfDebug( __METHOD__ . ": User can't edit\n" );
 
-                       // track block with a cookie if it doesn't exists already
-                       $this->context->getUser()->trackBlockWithCookie();
+                       if ( $this->context->getUser()->getBlock() ) {
+                               // track block with a cookie if it doesn't exists already
+                               $this->context->getUser()->trackBlockWithCookie();
+
+                               // Auto-block user's IP if the account was "hard" blocked
+                               if ( !wfReadOnly() ) {
+                                       DeferredUpdates::addCallableUpdate( function () {
+                                               $this->context->getUser()->spreadAnyEditBlock();
+                                       } );
+                               }
 
-                       // Auto-block user's IP if the account was "hard" blocked
-                       if ( !wfReadOnly() ) {
-                               DeferredUpdates::addCallableUpdate( function () {
-                                       $this->context->getUser()->spreadAnyEditBlock();
-                               } );
+                               $config = $this->context->getConfig();
+                               if ( $config->get( 'EnableBlockNoticeStats' ) ) {
+                                       $wiki = $config->get( 'DBname' );
+                                       $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
+                                       $statsd->increment( 'BlockNotices.' . $wiki . '.WikitextEditor.shown' );
+                               }
                        }
                        $this->displayPermissionsError( $permErrors );