* Insert a block into the block table. Will fail if there is a conflicting
* block (same name and options) already in the database.
*
- * @param DatabaseBase $dbw If you have one available
+ * @param IDatabase $dbw If you have one available
* @return bool|array False on failure, assoc array on success:
* ('id' => block ID, 'autoIds' => array of autoblock IDs)
*/
/**
* Get an array suitable for passing to $dbw->insert() or $dbw->update()
- * @param DatabaseBase $db
+ * @param IDatabase $db
* @return array
*/
protected function getDatabaseArray( $db = null ) {
* @return bool
*/
public static function isWhitelistedFromAutoblocks( $ip ) {
- global $wgMemc;
-
// Try to get the autoblock_whitelist from the cache, as it's faster
// than getting the msg raw and explode()'ing it.
- $key = wfMemcKey( 'ipb', 'autoblock', 'whitelist' );
- $lines = $wgMemc->get( $key );
- if ( !$lines ) {
- $lines = explode( "\n", wfMessage( 'autoblock_whitelist' )->inContentLanguage()->plain() );
- $wgMemc->set( $key, $lines, 3600 * 24 );
- }
+ $cache = ObjectCache::getMainWANInstance();
+ $lines = $cache->getWithSetCallback(
+ wfMemcKey( 'ipb', 'autoblock', 'whitelist' ),
+ $cache::TTL_DAY,
+ function () {
+ return explode( "\n",
+ wfMessage( 'autoblock_whitelist' )->inContentLanguage()->plain() );
+ }
+ );
wfDebug( "Checking the autoblock whitelist..\n" );