Flag internal page retrieve/save cycles with EDIT_INTERNAL
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 6 Jun 2016 23:00:33 +0000 (16:00 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 8 Jun 2016 01:29:57 +0000 (18:29 -0700)
This is used to avoid edit stash checks and stats noise.

Bug: T136678
Change-Id: I6158b8b218240ef3875f2d1d2e8ca3bc2f69f980

includes/Defines.php
includes/jobqueue/jobs/DoubleRedirectJob.php
includes/page/WikiPage.php
includes/specials/SpecialChangeContentModel.php

index d2b3443..fe5083e 100644 (file)
@@ -183,6 +183,7 @@ define( 'EDIT_SUPPRESS_RC', 8 );
 define( 'EDIT_FORCE_BOT', 16 );
 define( 'EDIT_DEFER_UPDATES', 32 ); // Unused since 1.27
 define( 'EDIT_AUTOSUMMARY', 64 );
+define( 'EDIT_INTERNAL', 128 );
 /**@}*/
 
 /**@{
index 617c32b..c6d8ec5 100644 (file)
@@ -167,7 +167,8 @@ class DoubleRedirectJob extends Job {
                $reason = wfMessage( 'double-redirect-fixed-' . $this->reason,
                        $this->redirTitle->getPrefixedText(), $newTitle->getPrefixedText()
                )->inContentLanguage()->text();
-               $article->doEditContent( $newContent, $reason, EDIT_UPDATE | EDIT_SUPPRESS_RC, false, $user );
+               $flags = EDIT_UPDATE | EDIT_SUPPRESS_RC | EDIT_INTERNAL;
+               $article->doEditContent( $newContent, $reason, $flags, false, $user );
                $wgUser = $oldUser;
 
                return true;
index 13e5f14..a3c3ece 100644 (file)
@@ -1480,6 +1480,8 @@ class WikiPage implements Page, IDBAccessObject {
         *          Mark the edit a "bot" edit regardless of user rights
         *      EDIT_AUTOSUMMARY
         *          Fill in blank summaries with generated text where possible
+        *      EDIT_INTERNAL
+        *          Signal that the page retrieve/save cycle happened entirely in this request.
         *
         * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the
         * article will be detected. If EDIT_UPDATE is specified and the article
@@ -1540,6 +1542,8 @@ class WikiPage implements Page, IDBAccessObject {
         *          Mark the edit a "bot" edit regardless of user rights
         *      EDIT_AUTOSUMMARY
         *          Fill in blank summaries with generated text where possible
+        *      EDIT_INTERNAL
+        *          Signal that the page retrieve/save cycle happened entirely in this request.
         *
         * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the
         * article will be detected. If EDIT_UPDATE is specified and the article
@@ -1627,8 +1631,14 @@ class WikiPage implements Page, IDBAccessObject {
                        $summary = $handler->getAutosummary( $old_content, $content, $flags );
                }
 
+               // Avoid statsd noise and wasted cycles check the edit stash (T136678)
+               if ( ( $flags & EDIT_INTERNAL ) || ( $flags & EDIT_FORCE_BOT ) ) {
+                       $useCache = false;
+               } else {
+                       $useCache = true;
+               }
+
                // Get the pre-save transform content and final parser output
-               $useCache = !( $flags & EDIT_FORCE_BOT ); // avoid statsd noise (T136678)
                $editInfo = $this->prepareContentForEdit( $content, null, $user, $serialFormat, $useCache );
                $pstContent = $editInfo->pstContent; // Content object
                $meta = [
@@ -3142,7 +3152,7 @@ class WikiPage implements Page, IDBAccessObject {
                $summary = $wgContLang->truncate( $summary, 255 );
 
                // Save
-               $flags = EDIT_UPDATE;
+               $flags = EDIT_UPDATE | EDIT_INTERNAL;
 
                if ( $guser->isAllowed( 'minoredit' ) ) {
                        $flags |= EDIT_MINOR;
index c7a650c..ccbb275 100644 (file)
@@ -192,6 +192,7 @@ class SpecialChangeContentModel extends FormSpecialPage {
                        $newContent = ContentHandler::getForModelID( $data['model'] )->makeEmptyContent();
                }
                $flags = $this->oldRevision ? EDIT_UPDATE : EDIT_NEW;
+               $flags |= EDIT_INTERNAL;
                if ( $user->isAllowed( 'bot' ) ) {
                        $flags |= EDIT_FORCE_BOT;
                }