r34883 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34882‎ | r34883 | r34884 >
Date:19:09, 15 May 2008
Author:aaron
Status:old
Tags:
Comment:
Don't promote users that were blocked before (bug 14143)
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -166,6 +166,7 @@
167167 'userpage' => true, # user must have a userpage?
168168 'userpageBytes' => 100, # if userpage is needed, what is the min size?
169169 'uniqueIPAddress' => true, # If $wgPutIPinRC is true, users sharing IPs won't be promoted
 170+ 'neverBlocked' => true, # Can user that were blocked be promoted?
170171 'noSorbsMatches' => false, # If $wgSorbsUrl is set, do not promote users that match
171172 );
172173
@@ -2023,7 +2024,6 @@
20242025 return true;
20252026 }
20262027 # Do not re-add status if it was previously removed!
2027 - # A special entry is made in the log whenever an editor looses their rights.
20282028 $p = self::getUserParams( $user );
20292029 if( isset($params['demoted']) && $params['demoted'] ) {
20302030 wfProfileOut( __METHOD__ );
@@ -2096,13 +2096,30 @@
20972097 wfProfileOut( __METHOD__ );
20982098 return true;
20992099 }
 2100+ # Check if user was ever blocked before
 2101+ if( $wgFlaggedRevsAutopromote['neverBlocked'] ) {
 2102+ $dbr = wfGetDB( DB_SLAVE );
 2103+ $blocked = $dbr->selectField( 'logging', '1',
 2104+ array( 'log_namespace' => NS_USER,
 2105+ 'log_title' => $user->getUserPage()->getDBKey(),
 2106+ 'log_type' => 'block',
 2107+ 'log_action' => 'block' ),
 2108+ __METHOD__,
 2109+ array( 'USE INDEX' => 'user_time' ) );
 2110+ if( $blocked ) {
 2111+ # Make a key to store the results
 2112+ $wgMemc->set( $key, 'true', 3600*24*7 );
 2113+ wfProfileOut( __METHOD__ );
 2114+ return true;
 2115+ }
 2116+ }
21002117 # See if the page actually has sufficient content...
21012118 if( $wgFlaggedRevsAutopromote['userpage'] ) {
21022119 if( !$user->getUserPage()->exists() ) {
21032120 wfProfileOut( __METHOD__ );
21042121 return true;
21052122 }
2106 - $dbr = wfGetDB( DB_SLAVE );
 2123+ $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE );
21072124 $size = $dbr->selectField( 'page', 'page_len',
21082125 array( 'page_namespace' => $user->getUserPage()->getNamespace(),
21092126 'page_title' => $user->getUserPage()->getDBKey() ),
@@ -2141,7 +2158,6 @@
21422159 }
21432160 if( $benchmarks < $needed ) {
21442161 # Make a key to store the results
2145 - $key = wfMemcKey( 'flaggedrevs', 'autopromote-skip', $user->getID() );
21462162 $wgMemc->set( $key, 'true', 3600*24*$spacing*($benchmarks - $needed - 1) );
21472163 wfProfileOut( __METHOD__ );
21482164 return true;
@@ -2159,7 +2175,6 @@
21602176 array( 'USE INDEX' => 'rc_ip' ) );
21612177 if( $shared ) {
21622178 # Make a key to store the results
2163 - $key = wfMemcKey( 'flaggedrevs', 'autopromote-skip', $user->getID() );
21642179 $wgMemc->set( $key, 'true', 3600*24*7 );
21652180 wfProfileOut( __METHOD__ );
21662181 return true;
@@ -2171,7 +2186,6 @@
21722187 $ip = wfGetIP();
21732188 if( !in_array($ip,$wgProxyWhitelist) && $user->inDnsBlacklist( $ip, $wgSorbsUrl ) ) {
21742189 # Make a key to store the results
2175 - $key = wfMemcKey( 'flaggedrevs', 'autopromote-skip', $user->getID() );
21762190 $wgMemc->set( $key, 'true', 3600*24*7 );
21772191 wfProfileOut( __METHOD__ );
21782192 return true;

Status & tagging log