Introduce 'PingLimiter' hook for overriding the result of User::pingLimiter()
authorRob Church <robchurch@users.mediawiki.org>
Fri, 22 Dec 2006 20:21:14 +0000 (20:21 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Fri, 22 Dec 2006 20:21:14 +0000 (20:21 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/User.php

index 371fb34..a1c7ce4 100644 (file)
@@ -376,6 +376,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   patrolled automatically
 * Users who do not have the "autopatrol" permission will no longer be able
   to mark their own edits as patrolled
+* Introduce 'PingLimiter' hook; see docs/hooks.txt for more information
 
 == Languages updated ==
 
index 104a665..66b3f3c 100644 (file)
@@ -416,6 +416,13 @@ my talk page, my contributions" etc).
 &$personal_urls: Array of link specifiers (see SkinTemplate.php)
 &$title: Title object representing the current page
 
+'PingLimiter': Allows extensions to override the results of User::pingLimiter()
+&$user : User performing the action
+$action : Action being performed
+&$result : Whether or not the action should be prevented
+Change $result and return false to give a definitive answer, otherwise
+the built-in rate limiting checks are used, if enabled.
+
 'SiteNoticeBefore': Before the sitenotice/anonnotice is composed
 &$siteNotice: HTML returned as the sitenotice
 Return true to allow the normal method of notice selection/rendering to work,
index ae92160..1febe51 100644 (file)
@@ -920,6 +920,13 @@ class User {
         * @public
         */
        function pingLimiter( $action='edit' ) {
+       
+               # Call the 'PingLimiter' hook
+               $result = false;
+               if( !wfRunHooks( 'PingLimiter', array( &$this, $action, $result ) ) ) {
+                       return $result;
+               }
+               
                global $wgRateLimits, $wgRateLimitsExcludedGroups;
                if( !isset( $wgRateLimits[$action] ) ) {
                        return false;