r26335 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26334‎ | r26335 | r26336 >
Date:00:19, 3 October 2007
Author:brion
Status:old
Tags:
Comment:
Break spam blacklist log info out to a sep file
Modified paths:
  • /trunk/extensions/SpamBlacklist/SpamBlacklist.php (modified) (history)
  • /trunk/extensions/SpamBlacklist/SpamBlacklist_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SpamBlacklist/SpamBlacklist.php
@@ -69,7 +69,7 @@
7070
7171 $spamObj = wfSpamBlacklistObject();
7272 if( !$spamObj->isLocalSource( $editPage->mTitle ) ) {
73 - wfDebug( "Spam blacklist validator: [[$thisPageName]] not a local blacklist\n" );
 73+ wfDebugLog( 'SpamBlacklist', "Spam blacklist validator: [[$thisPageName]] not a local blacklist\n" );
7474 return true;
7575 }
7676
@@ -77,7 +77,7 @@
7878
7979 $badLines = SpamRegexBatch::getBadLines( $lines );
8080 if( $badLines ) {
81 - wfDebug( "Spam blacklist validator: [[$thisPageName]] given invalid input lines: " .
 81+ wfDebugLog( 'SpamBlacklist', "Spam blacklist validator: [[$thisPageName]] given invalid input lines: " .
8282 implode( ', ', $badLines ) . "\n" );
8383
8484 $badList = "*<tt>" .
@@ -92,7 +92,7 @@
9393 "<br clear='all' />\n";
9494 return true;
9595 } else {
96 - wfDebug( "Spam blacklist validator: [[$thisPageName]] ok or empty blacklist\n" );
 96+ wfDebugLog( 'SpamBlacklist', "Spam blacklist validator: [[$thisPageName]] ok or empty blacklist\n" );
9797 return true;
9898 }
9999 }
Index: trunk/extensions/SpamBlacklist/SpamBlacklist_body.php
@@ -86,11 +86,11 @@
8787 $fname = 'SpamBlacklist::getRegex';
8888 wfProfileIn( $fname );
8989
90 - wfDebug( "Loading spam regex..." );
 90+ wfDebugLog( 'SpamBlacklist', "Loading spam regex..." );
9191
9292 if ( count( $this->files ) == 0 ){
9393 # No lists
94 - wfDebug( "no files specified\n" );
 94+ wfDebugLog( 'SpamBlacklist', "no files specified\n" );
9595 wfProfileOut( $fname );
9696 return array();
9797 }
@@ -99,7 +99,7 @@
100100 // server where not all wikis have the same configuration.
101101 $cachedRegexes = $wgMemc->get( "$wgDBname:spam_blacklist_regexes" );
102102 if( is_array( $cachedRegexes ) ) {
103 - wfDebug( "Got shared spam regexes from cache\n" );
 103+ wfDebugLog( 'SpamBlacklist', "Got shared spam regexes from cache\n" );
104104 wfProfileOut( $fname );
105105 return $cachedRegexes;
106106 }
@@ -113,13 +113,13 @@
114114 function clearCache() {
115115 global $wgMemc, $wgDBname;
116116 $wgMemc->delete( "$wgDBname:spam_blacklist_regexes" );
117 - wfDebug( "Spam blacklist local cache cleared.\n" );
 117+ wfDebugLog( 'SpamBlacklist', "Spam blacklist local cache cleared.\n" );
118118 }
119119
120120 function buildSharedBlacklists() {
121121 $regexes = array();
122122 # Load lists
123 - wfDebug( "Constructing spam blacklist\n" );
 123+ wfDebugLog( 'SpamBlacklist', "Constructing spam blacklist\n" );
124124 foreach ( $this->files as $fileName ) {
125125 if ( preg_match( '/^DB: ([\w-]*) (.*)$/', $fileName, $matches ) ) {
126126 $text = $this->getArticleText( $matches[1], $matches[2] );
@@ -127,7 +127,7 @@
128128 $text = $this->getHttpText( $fileName );
129129 } else {
130130 $text = file_get_contents( $fileName );
131 - wfDebug( "got from file $fileName\n" );
 131+ wfDebugLog( 'SpamBlacklist', "got from file $fileName\n" );
132132 }
133133
134134 // Build a separate batch of regexes from each source.
@@ -159,15 +159,15 @@
160160 $warning = $messageMemc->get( $warningKey );
161161
162162 if ( !is_string( $httpText ) || ( !$warning && !mt_rand( 0, $this->warningChance ) ) ) {
163 - wfDebug( "Loading spam blacklist from $fileName\n" );
 163+ wfDebugLog( 'SpamBlacklist', "Loading spam blacklist from $fileName\n" );
164164 $httpText = $this->getHTTP( $fileName );
165165 if( $httpText === false ) {
166 - wfDebug( "Error loading blacklist from $fileName\n" );
 166+ wfDebugLog( 'SpamBlacklist', "Error loading blacklist from $fileName\n" );
167167 }
168168 $messageMemc->set( $warningKey, 1, $this->warningTime );
169169 $messageMemc->set( $key, $httpText, $this->expiryTime );
170170 } else {
171 - wfDebug( "Got spam blacklist from HTTP cache for $fileName\n" );
 171+ wfDebugLog( 'SpamBlacklist', "Got spam blacklist from HTTP cache for $fileName\n" );
172172 }
173173 return $httpText;
174174 }
@@ -212,7 +212,7 @@
213213
214214 # Strip whitelisted URLs from the match
215215 if( is_array( $whitelists ) ) {
216 - wfDebug( "Excluding whitelisted URLs from " . count( $whitelists ) .
 216+ wfDebugLog( 'SpamBlacklist', "Excluding whitelisted URLs from " . count( $whitelists ) .
217217 " regexes: " . implode( ', ', $whitelists ) . "\n" );
218218 foreach( $whitelists as $regex ) {
219219 wfSuppressWarnings();
@@ -222,7 +222,7 @@
223223 }
224224
225225 # Do the match
226 - wfDebug( "Checking text against " . count( $blacklists ) .
 226+ wfDebugLog( 'SpamBlacklist', "Checking text against " . count( $blacklists ) .
227227 " regexes: " . implode( ', ', $blacklists ) . "\n" );
228228 $retVal = false;
229229 foreach( $blacklists as $regex ) {
@@ -230,7 +230,7 @@
231231 $check = preg_match( $regex, $links, $matches );
232232 wfRestoreWarnings();
233233 if( $check ) {
234 - wfDebug( "Match!\n" );
 234+ wfDebugLog( 'SpamBlacklist', "Match!\n" );
235235 EditPage::spamPage( $matches[0] );
236236 $retVal = true;
237237 break;
@@ -251,7 +251,7 @@
252252 * @param string $article
253253 */
254254 function getArticleText( $db, $article ) {
255 - wfDebug( "Fetching local spam blacklist from '$article' on '$db'...\n" );
 255+ wfDebugLog( 'SpamBlacklist', "Fetching local spam blacklist from '$article' on '$db'...\n" );
256256 global $wgDBname;
257257 $dbr = wfGetDB( DB_READ );
258258 $dbr->selectDB( $db );
@@ -386,7 +386,7 @@
387387 // slower if there's a lot of blacklist lines, but one
388388 // broken line won't take out hundreds of its brothers.
389389 if( $fileName ) {
390 - wfDebug( "Spam blacklist warning: bogus line in $fileName\n" );
 390+ wfDebugLog( 'SpamBlacklist', "Spam blacklist warning: bogus line in $fileName\n" );
391391 }
392392 return SpamRegexBatch::buildRegexes( $lines, 0 );
393393 }

Status & tagging log