Merge "Reduced the DOS potential of 404 page floods"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 22 Sep 2015 00:58:54 +0000 (00:58 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 22 Sep 2015 00:58:54 +0000 (00:58 +0000)
includes/page/Article.php
includes/page/WikiPage.php
languages/i18n/en.json
languages/i18n/qqq.json

index 29a38ba..56b9520 100644 (file)
@@ -1235,18 +1235,33 @@ class Article implements Page {
 
                Hooks::run( 'ShowMissingArticle', array( $this ) );
 
-               // Give extensions a chance to hide their (unrelated) log entries
-               $logTypes = array( 'delete', 'move' );
-               $conds = array( "log_action != 'revision'" );
-               Hooks::run( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) );
-
-               # Show delete and move logs
-               LogEventsList::showLogExtract( $outputPage, $logTypes, $title, '',
-                       array( 'lim' => 10,
-                               'conds' => $conds,
-                               'showIfEmpty' => false,
-                               'msgKey' => array( 'moveddeleted-notice' ) )
-               );
+               # Show delete and move logs if there were any such events.
+               # The logging query can DOS the site when bots/crawlers cause 404 floods,
+               # so be careful showing this. 404 pages must be cheap as they are hard to cache.
+               $cache = ObjectCache::getMainStashInstance();
+               $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
+               $loggedIn = $this->getContext()->getUser()->isLoggedIn();
+               if ( $loggedIn || $cache->get( $key ) ) {
+                       $logTypes = array( 'delete', 'move' );
+                       $conds = array( "log_action != 'revision'" );
+                       // Give extensions a chance to hide their (unrelated) log entries
+                       Hooks::run( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) );
+                       LogEventsList::showLogExtract(
+                               $outputPage,
+                               $logTypes,
+                               $title,
+                               '',
+                               array(
+                                       'lim' => 10,
+                                       'conds' => $conds,
+                                       'showIfEmpty' => false,
+                                       'msgKey' => array( $loggedIn
+                                               ? 'moveddeleted-notice'
+                                               : 'moveddeleted-notice-recent'
+                                       )
+                               )
+                       );
+               }
 
                if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
                        // If there's no backing content, send a 404 Not Found
index 30590cf..9504bc1 100644 (file)
@@ -2873,6 +2873,10 @@ class WikiPage implements Page, IDBAccessObject {
                        $dbw->commit( __METHOD__ );
                }
 
+               // Show log excerpt on 404 pages rather than just a link
+               $key = wfMemcKey( 'page-recent-delete', md5( $logTitle->getPrefixedText() ) );
+               ObjectCache::getMainStashInstance()->set( $key, 1, 86400 );
+
                $this->doDeleteUpdates( $id, $content );
 
                Hooks::run( 'ArticleDeleteComplete', array( &$this, &$user, $reason, $id, $content, $logEntry ) );
index 12bd910..6a93fac 100644 (file)
        "permissionserrorstext-withaction": "You do not have permission to $2, for the following {{PLURAL:$1|reason|reasons}}:",
        "recreate-moveddeleted-warn": "<strong>Warning: You are recreating a page that was previously deleted.</strong>\n\nYou should consider whether it is appropriate to continue editing this page.\nThe deletion and move log for this page are provided here for convenience:",
        "moveddeleted-notice": "This page has been deleted.\nThe deletion and move log for the page are provided below for reference.",
+       "moveddeleted-notice-recent": "Sorry, this page was recently deleted (within the last 24 hours).\nThe deletion and move log for the page are provided below for reference.",
        "log-fulllog": "View full log",
        "edit-hook-aborted": "Edit aborted by hook.\nIt gave no explanation.",
        "edit-gone-missing": "Could not update the page.\nIt appears to have been deleted.",
index 5b80d63..e86c298 100644 (file)
        "permissionserrorstext-withaction": "This message is \"with action\" version of {{msg-mw|Permissionserrorstext}}.\n\nParameters:\n* $1 - the number of reasons that were found why the action cannot be performed\n* $2 - one of the action-* messages (for example {{msg-mw|action-edit}}) or other such messages tagged with {{tl|doc-action}} in their documentation\n\nPlease report at [[Support]] if you are unable to properly translate this message. Also see [[phab:T16246]] (now closed) for background.",
        "recreate-moveddeleted-warn": "Warning shown when creating a page which has already been deleted. See for example [[Test]].",
        "moveddeleted-notice": "Shown on top of a deleted page in normal view modus ([{{canonicalurl:Test}} example]).",
+       "moveddeleted-notice-recent": "Shown on top of a recently deleted page in normal view modus ([{{canonicalurl:Test}} example]).",
        "log-fulllog": "Used as link text.",
        "edit-hook-aborted": "Used as error message.\n\nSee also:\n* {{msg-mw|edit-gone-missing}}\n* {{msg-mw|edit-conflict}}\n* {{msg-mw|edit-no-change}}\n* {{msg-mw|edit-already-exists}}",
        "edit-gone-missing": "Used as error message.\n\nSee also:\n* {{msg-mw|edit-hook-aborted}}\n* {{msg-mw|edit-conflict}}\n* {{msg-mw|edit-no-change}}\n* {{msg-mw|edit-already-exists}}",