Mailing List Archive

[MediaWiki-commits] [Gerrit] Reduced the DOS potential of 404 page floods - change (mediawiki/core)
Aaron Schulz has uploaded a new change for review.

https://gerrit.wikimedia.org/r/239319

Change subject: Reduced the DOS potential of 404 page floods
......................................................................

Reduced the DOS potential of 404 page floods

* showMissingArticle() will now only show the log excerpt
if the page was deleted very recently or if the viewing
user is logged in. Crawlers and poorly written bots tend
to be logged out, and logged in users are better tracked.
If many hits to the same recently deleted page are made,
then the innoDB buffer pool should actually have the
relevant index pages in cache (especially with query grouping).
* There have been several outages or DB performance problems
caused by crawlers or sloppy mirrors hitting many bogus pages
(due to bad URL generation, ect...). Previously a redis bloom
filter was used to handle this, but was removed due to high
complexity (especially if it was to be supported in multi-DC
setup). This is a simpler solution to keep 404 pages cheap,
as they cannot really be cached (there are enumerable possible
titles that never existed).

Change-Id: If948602a32deb16dba21d232d0c6128568a980d6
---
M includes/page/Article.php
M includes/page/WikiPage.php
M languages/i18n/en.json
M languages/i18n/qqq.json
4 files changed, 34 insertions(+), 14 deletions(-)


git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/19/239319/1

diff --git a/includes/page/Article.php b/includes/page/Article.php
index 120aa5c..4b7448f 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -1189,7 +1189,7 @@
* namespace, show the default message text. To be called from Article::view().
*/
public function showMissingArticle() {
- global $wgSend404Code;
+ global $wgSend404Code, $wgMemc;

$outputPage = $this->getContext()->getOutput();
// Whether the page is a root user page of an existing user (but not a subpage)
@@ -1234,18 +1234,32 @@

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.
+ $key = wfMemcKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
+ $loggedIn = $this->getContext()->getUser()->getId();
+ if ( $loggedIn || $wgMemc->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
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 69b675b..725e080 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2739,7 +2739,7 @@
public function doDeleteArticleReal(
$reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
) {
- global $wgUser, $wgContentHandlerUseDB;
+ global $wgUser, $wgContentHandlerUseDB, $wgMemc;

wfDebug( __METHOD__ . "\n" );

@@ -2872,6 +2872,10 @@
$dbw->commit( __METHOD__ );
}

+ // Show log excerpt on 404 pages rather than just a link
+ $key = wfMemcKey( 'page-recent-delete', md5( $logTitle->getPrefixedText() ) );
+ $wgMemc->set( $key, 1, 3600 );
+
$this->doDeleteUpdates( $id, $content );

Hooks::run( 'ArticleDeleteComplete', array( &$this, &$user, $reason, $id, $content, $logEntry ) );
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 3bf72d5..51e67b5 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -691,6 +691,7 @@
"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": "This page has been recently deleted (less than one hour ago).\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.",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index d3b5a99..a12dbaa 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -864,6 +864,7 @@
"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}}",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If948602a32deb16dba21d232d0c6128568a980d6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <aschulz@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Reduced the DOS potential of 404 page floods - change (mediawiki/core) [ In reply to ]
jenkins-bot has submitted this change and it was merged.

Change subject: Reduced the DOS potential of 404 page floods
......................................................................


Reduced the DOS potential of 404 page floods

* showMissingArticle() will now only show the log excerpt
if the page was deleted very recently or if the viewing
user is logged in. Crawlers and poorly written bots tend
to be logged out, and logged in users are better tracked.
If many hits to the same recently deleted page are made,
then the innoDB buffer pool should actually have the
relevant index pages in cache (especially with query grouping).
* There have been several outages or DB performance problems
caused by crawlers or sloppy mirrors hitting many bogus pages
(due to bad URL generation, ect...). Previously a redis bloom
filter was used to handle this, but was removed due to high
complexity (especially if it was to be supported in multi-DC
setup). This is a simpler solution to keep 404 pages cheap,
as they cannot really be cached (there are innumerable possible
titles that never existed).

Change-Id: If948602a32deb16dba21d232d0c6128568a980d6
---
M includes/page/Article.php
M includes/page/WikiPage.php
M languages/i18n/en.json
M languages/i18n/qqq.json
4 files changed, 33 insertions(+), 12 deletions(-)

Approvals:
Ori.livneh: Looks good to me, approved
MaxSem: Looks good to me, approved
jenkins-bot: Verified



diff --git a/includes/page/Article.php b/includes/page/Article.php
index 120aa5c..df94ecf 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -1234,18 +1234,33 @@

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
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 69b675b..7557b04 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2872,6 +2872,10 @@
$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 ) );
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 3bf72d5..e19452b 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -691,6 +691,7 @@
"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.",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index d3b5a99..a12dbaa 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -864,6 +864,7 @@
"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}}",

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If948602a32deb16dba21d232d0c6128568a980d6
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <aschulz@wikimedia.org>
Gerrit-Reviewer: Aaron Schulz <aschulz@wikimedia.org>
Gerrit-Reviewer: Alex Monk <krenair@gmail.com>
Gerrit-Reviewer: Catrope <roan.kattouw@gmail.com>
Gerrit-Reviewer: Faidon Liambotis <faidon@wikimedia.org>
Gerrit-Reviewer: Jcrespo <jcrespo@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklemail@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia@gmail.com>
Gerrit-Reviewer: MaxSem <maxsem.wiki@gmail.com>
Gerrit-Reviewer: Nemo bis <federicoleva@tiscali.it>
Gerrit-Reviewer: Ori.livneh <ori@wikimedia.org>
Gerrit-Reviewer: PleaseStand <pleasestand@live.com>
Gerrit-Reviewer: Siebrand <siebrand@kitano.nl>
Gerrit-Reviewer: Tim Starling <tstarling@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Reduced the DOS potential of 404 page floods - change (mediawiki/core) [ In reply to ]
Ori.livneh has uploaded a new change for review.

https://gerrit.wikimedia.org/r/240385

Change subject: Reduced the DOS potential of 404 page floods
......................................................................

Reduced the DOS potential of 404 page floods

* showMissingArticle() will now only show the log excerpt
if the page was deleted very recently or if the viewing
user is logged in. Crawlers and poorly written bots tend
to be logged out, and logged in users are better tracked.
If many hits to the same recently deleted page are made,
then the innoDB buffer pool should actually have the
relevant index pages in cache (especially with query grouping).
* There have been several outages or DB performance problems
caused by crawlers or sloppy mirrors hitting many bogus pages
(due to bad URL generation, ect...). Previously a redis bloom
filter was used to handle this, but was removed due to high
complexity (especially if it was to be supported in multi-DC
setup). This is a simpler solution to keep 404 pages cheap,
as they cannot really be cached (there are innumerable possible
titles that never existed).

Change-Id: If948602a32deb16dba21d232d0c6128568a980d6
(cherry picked from commit 549628abe5ebb6d994d47e87baac5ec04b108e3c)
---
M includes/page/Article.php
M includes/page/WikiPage.php
M languages/i18n/en.json
M languages/i18n/qqq.json
4 files changed, 33 insertions(+), 12 deletions(-)


git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/85/240385/1

diff --git a/includes/page/Article.php b/includes/page/Article.php
index 54db19c..6afb639 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -1224,18 +1224,33 @@

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
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 657c4d0..6a6fd4b 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2872,6 +2872,10 @@
$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 ) );
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 5859365..590d845 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -691,6 +691,7 @@
"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.",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index d3b5a99..a12dbaa 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -864,6 +864,7 @@
"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}}",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If948602a32deb16dba21d232d0c6128568a980d6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.26wmf23
Gerrit-Owner: Ori.livneh <ori@wikimedia.org>
Gerrit-Reviewer: Aaron Schulz <aschulz@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Reduced the DOS potential of 404 page floods - change (mediawiki/core) [ In reply to ]
Ori.livneh has submitted this change and it was merged.

Change subject: Reduced the DOS potential of 404 page floods
......................................................................


Reduced the DOS potential of 404 page floods

* showMissingArticle() will now only show the log excerpt
if the page was deleted very recently or if the viewing
user is logged in. Crawlers and poorly written bots tend
to be logged out, and logged in users are better tracked.
If many hits to the same recently deleted page are made,
then the innoDB buffer pool should actually have the
relevant index pages in cache (especially with query grouping).
* There have been several outages or DB performance problems
caused by crawlers or sloppy mirrors hitting many bogus pages
(due to bad URL generation, ect...). Previously a redis bloom
filter was used to handle this, but was removed due to high
complexity (especially if it was to be supported in multi-DC
setup). This is a simpler solution to keep 404 pages cheap,
as they cannot really be cached (there are innumerable possible
titles that never existed).

Change-Id: If948602a32deb16dba21d232d0c6128568a980d6
(cherry picked from commit 549628abe5ebb6d994d47e87baac5ec04b108e3c)
---
M includes/page/Article.php
M includes/page/WikiPage.php
M languages/i18n/en.json
M languages/i18n/qqq.json
4 files changed, 33 insertions(+), 12 deletions(-)

Approvals:
Ori.livneh: Verified; Looks good to me, approved



diff --git a/includes/page/Article.php b/includes/page/Article.php
index 54db19c..6afb639 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -1224,18 +1224,33 @@

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
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 657c4d0..6a6fd4b 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2872,6 +2872,10 @@
$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 ) );
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 5859365..590d845 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -691,6 +691,7 @@
"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.",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index d3b5a99..a12dbaa 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -864,6 +864,7 @@
"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}}",

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If948602a32deb16dba21d232d0c6128568a980d6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.26wmf23
Gerrit-Owner: Ori.livneh <ori@wikimedia.org>
Gerrit-Reviewer: Aaron Schulz <aschulz@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <ori@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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