r29133 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r29132‎ | r29133 | r29134 >
Date:23:02, 31 December 2007
Author:brion
Status:old
Tags:
Comment:
Use wfMemcKey() rather than hardcoding database name.
Modified paths:
  • /trunk/extensions/TitleBlacklist/TitleBlacklist.list.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TitleBlacklist/TitleBlacklist.list.php
@@ -14,9 +14,9 @@
1515 const VERSION = 1; //Blacklist format
1616
1717 public function load() {
18 - global $wgTitleBlacklistSources, $wgMemc, $wgDBname, $wgTitleBlacklistCaching;
 18+ global $wgTitleBlacklistSources, $wgMemc, $wgTitleBlacklistCaching;
1919 //Try to find something in the cache
20 - $cachedBlacklist = $wgMemc->get( "{$wgDBname}:title_blacklist_entries" );
 20+ $cachedBlacklist = $wgMemc->get( wfMemcKey( "title_blacklist_entries" ) );
2121 if( is_array( $cachedBlacklist ) && count( $cachedBlacklist ) > 1 && ( $cachedBlacklist[0]->getFormatVersion() != self::VERSION ) ) {
2222
2323 $this->mBlacklist = $cachedBlacklist;
@@ -29,7 +29,7 @@
3030 foreach( $sources as $source ) {
3131 $this->mBlacklist = array_merge( $this->mBlacklist, $this->parseBlacklist( $this->getBlacklistText( $source ) ) );
3232 }
33 - $wgMemc->set( "{$wgDBname}:title_blacklist_entries", $this->mBlacklist, $wgTitleBlacklistCaching['expiry'] );
 33+ $wgMemc->set( wfMemcKey( "title_blacklist_entries" ), $this->mBlacklist, $wgTitleBlacklistCaching['expiry'] );
3434 }
3535
3636 public function getBlacklistText( $source ) {
@@ -107,9 +107,9 @@
108108 }
109109
110110 public function getHttp( $url ) {
111 - global $messageMemc, $wgDBname, $wgTitleBlacklistCaching;
112 - $key = "title_blacklist_source:" . md5( $url );
113 - $warnkey = "{$wgDBname}:titleblacklistwarning:" . md5( $url );
 111+ global $messageMemc, $wgTitleBlacklistCaching;
 112+ $key = "title_blacklist_source:" . md5( $url ); // Global shared
 113+ $warnkey = wfMemcKey( "titleblacklistwarning", md5( $url ) );
114114 $result = $messageMemc->get( $key );
115115 $warn = $messageMemc->get( $warnkey );
116116 if ( !is_string( $result ) || ( !$warn && !mt_rand( 0, $wgTitleBlacklistCaching['warningchance'] ) ) ) {
@@ -121,8 +121,8 @@
122122 }
123123
124124 public function invalidate() {
125 - global $wgMemc, $wgDBname;
126 - $wgMemc->delete( "{$wgDBname}:title_blacklist_entries" );
 125+ global $wgMemc;
 126+ $wgMemc->delete( wfMemcKey( "title_blacklist_entries" ) );
127127 }
128128
129129 public function validate( $blacklist ) {

Status & tagging log