X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FEditPage.php;h=34062c062170b73a65da26b21bf7d1e92df8d3cd;hb=63c1c841d88f4dc572ceded8b48bd44937713ec6;hp=2b1bd7ba6d380abaec273ad69d93844ab81e389f;hpb=830a60aa827cdb44af17452e6b82e1065e00d8ad;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 2b1bd7ba6d..34062c0621 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -3543,15 +3543,7 @@ HTML
// 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( '
$1
', "yourdiff" );
@@ -3571,6 +3563,18 @@ HTML
}
}
+ 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() );
+ }
+ }
+
/**
* @return string
*/
@@ -3683,8 +3687,6 @@ HTML
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 @@ HTML
$this->context->msg( 'session_fail_preview_html' )->text() . "",
true, /* interface */true );
}
- $stats->increment( 'edit.failures.session_loss' );
+ $this->incrementEditFailureStats( 'session_loss' );
return $parsedNote;
}
@@ -3721,15 +3723,15 @@ HTML
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 @@ HTML
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