jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/334403 )

Change subject: EditPage: Factor stats collection into private methods
......................................................................


EditPage: Factor stats collection into private methods

Change-Id: Iad54ee22584077c6a7be6f2b050c3c4686b408c4
---
M includes/EditPage.php
1 file changed, 22 insertions(+), 15 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/EditPage.php b/includes/EditPage.php
index e070ca3..5193860 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -3543,15 +3543,7 @@
                // Avoid PHP 7.1 warning of passing $this by reference
                $editPage = $this;
                if ( Hooks::run( 'EditPageBeforeConflictDiff', [ &$editPage, 
&$wgOut ] ) ) {
-                       $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
-                       $stats->increment( 'edit.failures.conflict' );
-                       // Only include 'standard' namespaces to avoid creating 
unknown numbers of statsd metrics
-                       if (
-                               $this->mTitle->getNamespace() >= NS_MAIN &&
-                               $this->mTitle->getNamespace() <= 
NS_CATEGORY_TALK
-                       ) {
-                               $stats->increment( 
'edit.failures.conflict.byNamespaceId.' . $this->mTitle->getNamespace() );
-                       }
+                       $this->incrementConflictStats();
 
                        $wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourdiff" );
 
@@ -3568,6 +3560,18 @@
 
                        $wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourtext" );
                        $this->showTextbox2();
+               }
+       }
+
+       private function incrementConflictStats() {
+               $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
+               $stats->increment( 'edit.failures.conflict' );
+               // Only include 'standard' namespaces to avoid creating unknown 
numbers of statsd metrics
+               if (
+                       $this->mTitle->getNamespace() >= NS_MAIN &&
+                       $this->mTitle->getNamespace() <= NS_CATEGORY_TALK
+               ) {
+                       $stats->increment( 
'edit.failures.conflict.byNamespaceId.' . $this->mTitle->getNamespace() );
                }
        }
 
@@ -3683,8 +3687,6 @@
                global $wgOut, $wgRawHtml, $wgLang;
                global $wgAllowUserCss, $wgAllowUserJs;
 
-               $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
-
                if ( $wgRawHtml && !$this->mTokenOk ) {
                        // Could be an offsite preview attempt. This is very 
unsafe if
                        // HTML is enabled, as it could be an attack.
@@ -3697,7 +3699,7 @@
                                        $this->context->msg( 
'session_fail_preview_html' )->text() . "</div>",
                                        true, /* interface */true );
                        }
-                       $stats->increment( 'edit.failures.session_loss' );
+                       $this->incrementEditFailureStats( 'session_loss' );
                        return $parsedNote;
                }
 
@@ -3721,15 +3723,15 @@
                        if ( $this->mTriedSave && !$this->mTokenOk ) {
                                if ( $this->mTokenOkExceptSuffix ) {
                                        $note = $this->context->msg( 
'token_suffix_mismatch' )->plain();
-                                       $stats->increment( 
'edit.failures.bad_token' );
+                                       $this->incrementEditFailureStats( 
'bad_token' );
                                } else {
                                        $note = $this->context->msg( 
'session_fail_preview' )->plain();
-                                       $stats->increment( 
'edit.failures.session_loss' );
+                                       $this->incrementEditFailureStats( 
'session_loss' );
                                }
                        } elseif ( $this->incompleteForm ) {
                                $note = $this->context->msg( 
'edit_form_incomplete' )->plain();
                                if ( $this->mTriedSave ) {
-                                       $stats->increment( 
'edit.failures.incomplete_form' );
+                                       $this->incrementEditFailureStats( 
'incomplete_form' );
                                }
                        } else {
                                $note = $this->context->msg( 'previewnote' 
)->plain() . ' ' . $continueEditing;
@@ -3817,6 +3819,11 @@
                return $previewhead . $previewHTML . 
$this->previewTextAfterContent;
        }
 
+       private function incrementEditFailureStats( $failureType ) {
+               $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
+               $stats->increment( 'edit.failures.' . $failureType );
+       }
+
        /**
         * Get parser options for a preview
         * @return ParserOptions

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iad54ee22584077c6a7be6f2b050c3c4686b408c4
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to