From: Dayllan Maza Date: Thu, 8 Nov 2018 04:03:53 +0000 (-0500) Subject: Add block notice stats on EditPage. X-Git-Tag: 1.34.0-rc.0~3408^2~1 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=49bb28b557e08ef564459665fab461e75376c5c6;p=lhc%2Fweb%2Fwiklou.git Add block notice stats on EditPage. Monitoring block notices is behind $wgEnableBlockNoticeStats config flag which is set to false by default. The reason behind this metric is to get an idea on how frequently blocked users attempt to edit a page. Similar tracking is being added to MobileFrontend and VisualEditor. Bug: T201718 Change-Id: I6bd1c95548616677e1f72ba6bcfc6f2b551c1ca6 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 2d1681cc3e..d05867fdc1 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -9055,6 +9055,16 @@ $wgTagStatisticsNewTable = false; */ $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 diff --git a/includes/EditPage.php b/includes/EditPage.php index 0f7d9a7a39..6b4325e104 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -619,14 +619,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 );