Add ThrottledError to throw when the user hits a rate limit.
authorHappy-melon <happy-melon@users.mediawiki.org>
Mon, 18 Apr 2011 22:29:23 +0000 (22:29 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Mon, 18 Apr 2011 22:29:23 +0000 (22:29 +0000)
includes/AutoLoader.php
includes/Exception.php
includes/OutputPage.php

index ae6cd31..2a92f8c 100644 (file)
@@ -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',
index 0d3cc77..0e07194 100644 (file)
@@ -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
  */
index 67a634d..2470d62 100644 (file)
@@ -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;
        }
 
        /**