r95152 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95151‎ | r95152 | r95153 >
Date:16:38, 21 August 2011
Author:raymond
Status:resolved (Comments)
Tags:
Comment:
New hook point to exempt an IP address from the account creation throttle. Redo of r95041 per Niklas CR
Needed for a new extension to make (mass) account creation easier for schools/colleges etc
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -849,6 +849,9 @@
850850 $editToken: The user's edit token.
851851 &$hookErr: Out-param for the error. Passed as the parameters to OutputPage::showErrorPage.
852852
 853+'exemptFromAccountCreationThrottle': Exemption from the account creation throttle
 854+$ip: The ip address of the user
 855+
853856 'ExtensionTypes': called when generating the extensions credits, use this to change the tables headers
854857 &$extTypes: associative array of extensions types
855858
Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -45,6 +45,7 @@
4646 although they are not used there.
4747 * (bug 30451) Add page_props to RefreshLinks::deleteLinksFromNonexistent
4848 * (bug 30450) Clear page_props table on page deletion
 49+* Hook added to check for exempt from account creation throttle
4950
5051 === Bug fixes in 1.19 ===
5152 * $wgUploadNavigationUrl should be used for file redlinks if
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -377,17 +377,23 @@
378378 return false;
379379 }
380380
381 - if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) {
382 - $key = wfMemcKey( 'acctcreate', 'ip', $ip );
383 - $value = $wgMemc->get( $key );
384 - if ( !$value ) {
385 - $wgMemc->set( $key, 0, 86400 );
 381+ // Hook point to check for exempt from account creation throttle
 382+ if ( !wfRunHooks( 'exemptFromAccountCreationThrottle', array( $ip ) ) ) {
 383+ wfDebug( "LoginForm::exemptFromAccountCreationThrottle: a hook allowed account creation w/o throttle\n" );
 384+ } else {
 385+ if ( ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) ) {
 386+ wfDebugLog( 'CACT', "IN der core Throttle Abfrage\n" );
 387+ $key = wfMemcKey( 'acctcreate', 'ip', $ip );
 388+ $value = $wgMemc->get( $key );
 389+ if ( !$value ) {
 390+ $wgMemc->set( $key, 0, 86400 );
 391+ }
 392+ if ( $value >= $wgAccountCreationThrottle ) {
 393+ $this->throttleHit( $wgAccountCreationThrottle );
 394+ return false;
 395+ }
 396+ $wgMemc->incr( $key );
386397 }
387 - if ( $value >= $wgAccountCreationThrottle ) {
388 - $this->throttleHit( $wgAccountCreationThrottle );
389 - return false;
390 - }
391 - $wgMemc->incr( $key );
392398 }
393399
394400 if( !$wgAuth->addUser( $u, $this->mPassword, $this->mEmail, $this->mRealName ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r95165fu r95152: remove debug line.raymond18:15, 21 August 2011
r100241Change the hook case per CR r95152raymond17:15, 19 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95041New hook point to change $wgAccountCreationThrottle...raymond20:57, 19 August 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   18:05, 21 August 2011
wfDebugLog( 'CACT', "IN der core Throttle Abfrage\n" );

Also, I think ConfirmAccount might want to use this hook if I recall.

#Comment by Raymond (talk | contribs)   18:17, 21 August 2011

Thanks for CR. Fixed with r95152.

Yes, ConfirmAccount uses an identical check, I found with grep. I will add the hook later when the extension is more complete.

#Comment by 😂 (talk | contribs)   21:28, 27 September 2011

Also, general hook casing is UpperCamelCase. There's a few lowerCamelCase ones, but they're in the minority.

#Comment by Aaron Schulz (talk | contribs)   17:10, 19 October 2011

Yeah, I'd change the hook case.

#Comment by Raymond (talk | contribs)   17:15, 19 October 2011

Status & tagging log