Instrument edit failures
authorOri Livneh <ori@wikimedia.org>
Thu, 11 Jun 2015 23:38:46 +0000 (16:38 -0700)
committerOri.livneh <ori@wikimedia.org>
Thu, 11 Jun 2015 23:44:42 +0000 (23:44 +0000)
Users on enwiki's VPT are reporting a spike in the frequency of rejected edits
due to loss of session data. It is difficult to corroborate these reports when
we don't have any instrumentation for them in the code, and thus no visibility
into how frequently they are occurring in the wild.

Bug: T102199
Change-Id: I0c99f292002209cf2bf4376f97b8c70a6b1ec021

includes/EditPage.php

index e88baaf..ee67d01 100644 (file)
@@ -3464,6 +3464,8 @@ HTML
                global $wgOut, $wgUser, $wgRawHtml, $wgLang;
                global $wgAllowUserCss, $wgAllowUserJs;
 
+               $stats = $wgOut->getContext()->getStats();
+
                if ( $wgRawHtml && !$this->mTokenOk ) {
                        // Could be an offsite preview attempt. This is very unsafe if
                        // HTML is enabled, as it could be an attack.
@@ -3475,6 +3477,7 @@ HTML
                                $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
                                        wfMessage( 'session_fail_preview_html' )->text() . "</div>", true, /* interface */true );
                        }
+                       $stats->increment( 'edit.failures.session_loss' );
                        return $parsedNote;
                }
 
@@ -3498,11 +3501,16 @@ HTML
                        if ( $this->mTriedSave && !$this->mTokenOk ) {
                                if ( $this->mTokenOkExceptSuffix ) {
                                        $note = wfMessage( 'token_suffix_mismatch' )->plain();
+                                       $stats->increment( 'edit.failures.bad_token' );
                                } else {
                                        $note = wfMessage( 'session_fail_preview' )->plain();
+                                       $stats->increment( 'edit.failures.session_loss' );
                                }
                        } elseif ( $this->incompleteForm ) {
                                $note = wfMessage( 'edit_form_incomplete' )->plain();
+                               if ( $this->mTriedSave ) {
+                                       $stats->increment( 'edit.failures.incomplete_form' );
+                               }
                        } else {
                                $note = wfMessage( 'previewnote' )->plain() . ' ' . $continueEditing;
                        }