From f144bcfb6b766d4f0292c0b2286041bd411c5a48 Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Mon, 18 Apr 2011 22:29:23 +0000 Subject: [PATCH] Add ThrottledError to throw when the user hits a rate limit. --- includes/AutoLoader.php | 1 + includes/Exception.php | 17 +++++++++++++++++ includes/OutputPage.php | 11 +---------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index ae6cd310cd..2a92f8c1e1 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -226,6 +226,7 @@ $wgAutoloadLocalClasses = array( 'TitleArrayFromResult' => 'includes/TitleArray.php', 'TitleDependency' => 'includes/CacheDependency.php', 'TitleListDependency' => 'includes/CacheDependency.php', + 'ThrottledError' => 'includes/Exception.php', 'UnlistedSpecialPage' => 'includes/SpecialPage.php', 'UppercaseCollation' => 'includes/Collation.php', 'User' => 'includes/User.php', diff --git a/includes/Exception.php b/includes/Exception.php index 0d3cc776cf..0e0719445c 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -406,6 +406,23 @@ class ReadOnlyError extends ErrorPageError { } } +/** + * Show an error when the user hits a rate limit + */ +class ThrottledError extends ErrorPageError { + public function __construct(){ + parent::__construct( + 'actionthrottled', + 'actionthrottledtext' + ); + } + public function report(){ + global $wgOut; + $wgOut->setStatusCode( 503 ); + return parent::report(); + } +} + /** * Show an error when the user tries to do something whilst blocked */ diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 67a634d9c8..2470d62b7a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2158,16 +2158,7 @@ class OutputPage { * for when rate limiting has triggered. */ public function rateLimited() { - $this->setPageTitle( wfMsg( 'actionthrottled' ) ); - $this->setRobotPolicy( 'noindex,follow' ); - $this->setArticleRelated( false ); - $this->enableClientCache( false ); - $this->mRedirect = ''; - $this->clearHTML(); - $this->setStatusCode( 503 ); - $this->addWikiMsg( 'actionthrottledtext' ); - - $this->returnToMain( null, $this->getTitle() ); + throw new ThrottledError; } /** -- 2.20.1