<?php
-/**
- */
# Copyright (C) 2004 Brion Vibber <brion@pobox.com>
# http://www.mediawiki.org/
#
return true;
}
-
/**
* Return true if the wiki should create a new local account automatically
* when asked to login a user who doesn't exist locally but does in the
* @return Boolean
*/
public function allowPropChange( $prop = '' ) {
- if( $prop == 'realname' && is_callable( array( $this, 'allowRealNameChange' ) ) ) {
+ if ( $prop == 'realname' && is_callable( array( $this, 'allowRealNameChange' ) ) ) {
return $this->allowRealNameChange();
- } elseif( $prop == 'emailaddress' && is_callable( array( $this, 'allowEmailChange' ) ) ) {
+ } elseif ( $prop == 'emailaddress' && is_callable( array( $this, 'allowEmailChange' ) ) ) {
return $this->allowEmailChange();
- } elseif( $prop == 'nickname' && is_callable( array( $this, 'allowNickChange' ) ) ) {
+ } elseif ( $prop == 'nickname' && is_callable( array( $this, 'allowNickChange' ) ) ) {
return $this->allowNickChange();
} else {
return true;
* @param $realname String
* @return Boolean
*/
- public function addUser( $user, $password, $email='', $realname='' ) {
+ public function addUser( $user, $password, $email = '', $realname = '' ) {
return true;
}
-
/**
* Return true to prevent logins that don't authenticate here from being
* checked against the local database's password fields.
* @param $user User object.
* @param $autocreate Boolean: True if user is being autocreated on login
*/
- public function initUser( &$user, $autocreate=false ) {
+ public function initUser( &$user, $autocreate = false ) {
# Override this to do something.
}
public function getCanonicalName( $username ) {
return $username;
}
-
+
/**
* Get an instance of a User object
*
function __construct( $user ) {
# Override this!
}
-
+
public function getId() {
# Override this!
return -1;
}
-
+
public function isLocked() {
# Override this!
return false;
}
-
+
public function isHidden() {
# Override this!
return false;
}
-
+
public function resetAuthToken() {
# Override this!
return true;
# Extension classes are specified with $wgAutoloadClasses
# This array is a global instead of a static member of AutoLoader to work around a bug in APC
global $wgAutoloadLocalClasses;
+
$wgAutoloadLocalClasses = array(
# Includes
'AjaxDispatcher' => 'includes/AjaxDispatcher.php',
'ApiQueryLogEvents' => 'includes/api/ApiQueryLogEvents.php',
'ApiQueryProtectedTitles' => 'includes/api/ApiQueryProtectedTitles.php',
'ApiQueryRandom' => 'includes/api/ApiQueryRandom.php',
- 'ApiQueryRecentChanges'=> 'includes/api/ApiQueryRecentChanges.php',
+ 'ApiQueryRecentChanges' => 'includes/api/ApiQueryRecentChanges.php',
'ApiQueryRevisions' => 'includes/api/ApiQueryRevisions.php',
'ApiQuerySearch' => 'includes/api/ApiQuerySearch.php',
'ApiQuerySiteinfo' => 'includes/api/ApiQuerySiteinfo.php',
# The case can sometimes be wrong when unserializing PHP 4 objects
$filename = false;
$lowerClass = strtolower( $className );
+
foreach ( $wgAutoloadLocalClasses as $class2 => $file2 ) {
if ( strtolower( $class2 ) == $lowerClass ) {
$filename = $file2;
}
}
+
if ( !$filename ) {
- if( function_exists( 'wfDebug' ) )
+ if ( function_exists( 'wfDebug' ) )
wfDebug( "Class {$className} not found; skipped loading\n" );
+
# Give up
return false;
}
global $IP;
$filename = "$IP/$filename";
}
+
require( $filename );
+
return true;
}
static function loadAllExtensions() {
global $wgAutoloadClasses;
- foreach( $wgAutoloadClasses as $class => $file ) {
- if( !( class_exists( $class, false ) || interface_exists( $class, false ) ) ) {
+ foreach ( $wgAutoloadClasses as $class => $file ) {
+ if ( !( class_exists( $class, false ) || interface_exists( $class, false ) ) ) {
require( $file );
}
}
* This class checks if user can get extra rights
* because of conditions specified in $wgAutopromote
*/
+
class Autopromote {
/**
* Get the groups for the given user based on $wgAutopromote.
*/
public static function getAutopromoteGroups( User $user ) {
global $wgAutopromote;
+
$promote = array();
- foreach( $wgAutopromote as $group => $cond ) {
- if( self::recCheckCondition( $cond, $user ) )
+
+ foreach ( $wgAutopromote as $group => $cond ) {
+ if ( self::recCheckCondition( $cond, $user ) )
$promote[] = $group;
}
*/
private static function recCheckCondition( $cond, User $user ) {
$validOps = array( '&', '|', '^', '!' );
- if( is_array( $cond ) && count( $cond ) >= 2 && in_array( $cond[0], $validOps ) ) {
+
+ if ( is_array( $cond ) && count( $cond ) >= 2 && in_array( $cond[0], $validOps ) ) {
# Recursive condition
- if( $cond[0] == '&' ) {
- foreach( array_slice( $cond, 1 ) as $subcond )
- if( !self::recCheckCondition( $subcond, $user ) )
+ if ( $cond[0] == '&' ) {
+ foreach ( array_slice( $cond, 1 ) as $subcond ) {
+ if ( !self::recCheckCondition( $subcond, $user ) ) {
return false;
+ }
+ }
+
return true;
- } elseif( $cond[0] == '|' ) {
- foreach( array_slice( $cond, 1 ) as $subcond )
- if( self::recCheckCondition( $subcond, $user ) )
+ } elseif ( $cond[0] == '|' ) {
+ foreach ( array_slice( $cond, 1 ) as $subcond ) {
+ if ( self::recCheckCondition( $subcond, $user ) ) {
return true;
+ }
+ }
+
return false;
- } elseif( $cond[0] == '^' ) {
+ } elseif ( $cond[0] == '^' ) {
$res = null;
- foreach( array_slice( $cond, 1 ) as $subcond ) {
- if( is_null( $res ) )
+ foreach ( array_slice( $cond, 1 ) as $subcond ) {
+ if ( is_null( $res ) ) {
$res = self::recCheckCondition( $subcond, $user );
- else
- $res = ($res xor self::recCheckCondition( $subcond, $user ));
+ } else {
+ $res = ( $res xor self::recCheckCondition( $subcond, $user ) );
+ }
}
+
return $res;
} elseif ( $cond[0] = '!' ) {
- foreach( array_slice( $cond, 1 ) as $subcond )
- if( self::recCheckCondition( $subcond, $user ) )
+ foreach ( array_slice( $cond, 1 ) as $subcond ) {
+ if ( self::recCheckCondition( $subcond, $user ) ) {
return false;
+ }
+ }
+
return true;
}
}
# If we got here, the array presumably does not contain other condi-
# tions; it's not recursive. Pass it off to self::checkCondition.
- if( !is_array( $cond ) )
+ if ( !is_array( $cond ) ) {
$cond = array( $cond );
+ }
+
return self::checkCondition( $cond, $user );
}
* @return bool Whether the condition is true for the user
*/
private static function checkCondition( $cond, User $user ) {
- if( count( $cond ) < 1 )
+ if ( count( $cond ) < 1 ) {
return false;
+ }
+
switch( $cond[0] ) {
case APCOND_EMAILCONFIRMED:
- if( User::isValidEmailAddr( $user->getEmail() ) ) {
+ if ( User::isValidEmailAddr( $user->getEmail() ) ) {
global $wgEmailAuthentication;
- if( $wgEmailAuthentication ) {
+ if ( $wgEmailAuthentication ) {
return (bool)$user->getEmailAuthenticationTimestamp();
} else {
return true;
default:
$result = null;
wfRunHooks( 'AutopromoteCondition', array( $cond[0], array_slice( $cond, 1 ), $user, &$result ) );
- if( $result === null ) {
+ if ( $result === null ) {
throw new MWException( "Unrecognized condition {$cond[0]} for autopromotion!" );
}
+
return $result ? true : false;
}
}
if ( !isset( $this->db ) ) {
$this->db = wfGetDB( DB_SLAVE );
}
+
return $this->db;
}
// Partial range, not cached
wfDebug( __METHOD__ . ": from DB (uncacheable range)\n" );
$conds = $this->getConditions( $table );
+
// Use the from field in the condition rather than the joined page_id,
// because databases are stupid and don't necessarily propagate indexes.
if ( $startId ) {
$conds[] = "$fromField >= " . intval( $startId );
}
+
if ( $endId ) {
$conds[] = "$fromField <= " . intval( $endId );
}
+
$res = $this->getDB()->select(
array( $table, 'page' ),
array( 'page_namespace', 'page_title', 'page_id' ),
'ORDER BY' => $fromField
) );
$ta = TitleArray::newFromResult( $res );
+
wfProfileOut( __METHOD__ );
return $ta;
}
) );
$this->fullResultCache[$table] = $res;
}
+
$ta = TitleArray::newFromResult( $this->fullResultCache[$table] );
+
wfProfileOut( __METHOD__ );
return $ta;
}
default:
throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
}
+
return $conds;
}
}
$titleArray = $this->getLinks( $table );
+
return $titleArray->count();
}
if ( isset( $this->fullResultCache[$table] ) ) {
$cacheEntry = $this->partitionResult( $this->fullResultCache[$table], $batchSize );
wfDebug( __METHOD__ . ": got from full result cache\n" );
+
return $cacheEntry['batches'];
}
// Try memcached
global $wgMemc;
+
$memcKey = wfMemcKey(
'backlinks',
md5( $this->title->getPrefixedDBkey() ),
$table,
$batchSize
);
+
$memcValue = $wgMemc->get( $memcKey );
if ( is_array( $memcValue ) ) {
$cacheEntry = $memcValue;
wfDebug( __METHOD__ . ": got from memcached $memcKey\n" );
+
return $cacheEntry['batches'];
}
+
// Fetch from database
$this->getLinks( $table );
$cacheEntry = $this->partitionResult( $this->fullResultCache[$table], $batchSize );
// Save to memcached
$wgMemc->set( $memcKey, $cacheEntry, self::CACHE_EXPIRY );
+
wfDebug( __METHOD__ . ": got from database\n" );
return $cacheEntry['batches'];
}
$batches[] = array( $start, $end );
}
+
return array( 'numRows' => $numRows, 'batches' => $batches );
}
}
public function add( $key, $value, $exptime = 0 ) {
if ( $this->get( $key ) == false ) {
$this->set( $key, $value, $exptime );
+
return true;
}
}
if ( !$this->lock( $key ) ) {
return false;
}
+
$value = intval( $value );
$n = false;
$this->set( $key, $n ); // exptime?
}
$this->unlock( $key );
+
return $n;
}
}
public function debug( $text ) {
- if ( $this->debugMode )
+ if ( $this->debugMode ) {
wfDebug( "BagOStuff debug: $text\n" );
+ }
}
/**
protected function expire( $key ) {
$et = $this->bag[$key][1];
+
if ( ( $et == 0 ) || ( $et > time() ) ) {
return false;
}
+
$this->delete( $key );
+
return true;
}
if ( !isset( $this->bag[$key] ) ) {
return false;
}
+
if ( $this->expire( $key ) ) {
return false;
}
+
return $this->bag[$key][0];
}
if ( !isset( $this->bag[$key] ) ) {
return false;
}
+
unset( $this->bag[$key] );
+
return true;
}
protected function getDB() {
global $wgDBtype;
+
if ( !isset( $this->db ) ) {
/* We must keep a separate connection to MySQL in order to avoid deadlocks
* However, SQLite has an opposite behaviour.
$this->db->clearFlag( DBO_TRX );
}
}
+
return $this->db;
}
$db = $this->getDB();
$row = $db->selectRow( 'objectcache', array( 'value', 'exptime' ),
array( 'keyname' => $key ), __METHOD__ );
+
if ( !$row ) {
$this->debug( 'get: no matching rows' );
return false;
}
$this->debug( "get: retrieved data; expiry time is " . $row->exptime );
+
if ( $this->isExpired( $row->exptime ) ) {
$this->debug( "get: key has expired, deleting" );
try {
} catch ( DBQueryError $e ) {
$this->handleWriteError( $e );
}
+
return false;
}
+
return $this->unserialize( $db->decodeBlob( $row->value ) );
}
public function set( $key, $value, $exptime = 0 ) {
$db = $this->getDB();
$exptime = intval( $exptime );
- if ( $exptime < 0 ) $exptime = 0;
+
+ if ( $exptime < 0 ) {
+ $exptime = 0;
+ }
+
if ( $exptime == 0 ) {
$encExpiry = $this->getMaxDateTime();
} else {
- if ( $exptime < 3.16e8 ) # ~10 years
+ if ( $exptime < 3.16e8 ) { # ~10 years
$exptime += time();
+ }
+
$encExpiry = $db->timestamp( $exptime );
}
try {
$db->commit();
} catch ( DBQueryError $e ) {
$this->handleWriteError( $e );
+
return false;
}
+
return true;
}
public function delete( $key, $time = 0 ) {
$db = $this->getDB();
+
try {
$db->begin();
$db->delete( 'objectcache', array( 'keyname' => $key ), __METHOD__ );
$db->commit();
} catch ( DBQueryError $e ) {
$this->handleWriteError( $e );
+
return false;
}
+
return true;
}
if ( $row === false ) {
// Missing
$db->commit();
+
return false;
}
$db->delete( 'objectcache', array( 'keyname' => $key ), __METHOD__ );
if ( $this->isExpired( $row->exptime ) ) {
// Expired, do not reinsert
$db->commit();
+
return false;
}
$db->commit();
} catch ( DBQueryError $e ) {
$this->handleWriteError( $e );
+
return false;
}
+
return $newValue;
}
$db = $this->getDB();
$res = $db->select( 'objectcache', array( 'keyname' ), false, __METHOD__ );
$result = array();
+
foreach ( $res as $row ) {
$result[] = $row->keyname;
}
+
return $result;
}
public function expireAll() {
$db = $this->getDB();
$now = $db->timestamp();
+
try {
$db->begin();
$db->delete( 'objectcache', array( 'exptime < ' . $db->addQuotes( $now ) ), __METHOD__ );
public function deleteAll() {
$db = $this->getDB();
+
try {
$db->begin();
$db->delete( 'objectcache', '*', __METHOD__ );
*/
protected function serialize( &$data ) {
$serial = serialize( $data );
+
if ( function_exists( 'gzdeflate' ) ) {
return gzdeflate( $serial );
} else {
protected function unserialize( $serial ) {
if ( function_exists( 'gzinflate' ) ) {
$decomp = @gzinflate( $serial );
+
if ( false !== $decomp ) {
$serial = $decomp;
}
}
+
$ret = unserialize( $serial );
+
return $ret;
}
*/
protected function handleWriteError( $exception ) {
$db = $this->getDB();
+
if ( !$db->wasReadOnlyError() ) {
throw $exception;
}
+
try {
$db->rollback();
} catch ( DBQueryError $e ) {
}
+
wfDebug( __METHOD__ . ": ignoring query error\n" );
$db->ignoreErrors( false );
}
class APCBagOStuff extends BagOStuff {
public function get( $key ) {
$val = apc_fetch( $key );
+
if ( is_string( $val ) ) {
$val = unserialize( $val );
}
+
return $val;
}
public function set( $key, $value, $exptime = 0 ) {
apc_store( $key, serialize( $value ), $exptime );
+
return true;
}
public function delete( $key, $time = 0 ) {
apc_delete( $key );
+
return true;
}
$info = apc_cache_info( 'user' );
$list = $info['cache_list'];
$keys = array();
+
foreach ( $list as $entry ) {
$keys[] = $entry['info'];
}
+
return $keys;
}
}
class eAccelBagOStuff extends BagOStuff {
public function get( $key ) {
$val = eaccelerator_get( $key );
+
if ( is_string( $val ) ) {
$val = unserialize( $val );
}
+
return $val;
}
public function set( $key, $value, $exptime = 0 ) {
eaccelerator_put( $key, serialize( $value ), $exptime );
+
return true;
}
public function delete( $key, $time = 0 ) {
eaccelerator_rm( $key );
+
return true;
}
public function lock( $key, $waitTimeout = 0 ) {
eaccelerator_lock( $key );
+
return true;
}
public function unlock( $key ) {
eaccelerator_unlock( $key );
+
return true;
}
}
* @ingroup Cache
*/
class XCacheBagOStuff extends BagOStuff {
-
/**
* Get a value from the XCache object cache
*
*/
public function get( $key ) {
$val = xcache_get( $key );
- if ( is_string( $val ) )
+
+ if ( is_string( $val ) ) {
$val = unserialize( $val );
+ }
+
return $val;
}
*/
public function set( $key, $value, $expire = 0 ) {
xcache_set( $key, serialize( $value ), $expire );
+
return true;
}
*/
public function delete( $key, $time = 0 ) {
xcache_unset( $key );
+
return true;
}
}
public function __construct( $dir = false ) {
global $wgDBAhandler;
+
if ( $dir === false ) {
global $wgTmpDirectory;
$dir = $wgTmpDirectory;
}
+
$this->mFile = "$dir/mw-cache-" . wfWikiID();
$this->mFile .= '.db';
wfDebug( __CLASS__ . ": using cache file {$this->mFile}\n" );
function encode( $value, $expiry ) {
# Convert to absolute time
$expiry = $this->convertExpiry( $expiry );
+
return sprintf( '%010u', intval( $expiry ) ) . ' ' . serialize( $value );
}
} else {
$handle = $this->getWriter();
}
+
if ( !$handle ) {
wfDebug( "Unable to open DBA cache file {$this->mFile}\n" );
}
+
return $handle;
}
function getWriter() {
$handle = dba_open( $this->mFile, 'cl', $this->mHandler );
+
if ( !$handle ) {
wfDebug( "Unable to open DBA cache file {$this->mFile}\n" );
}
+
return $handle;
}
function get( $key ) {
wfProfileIn( __METHOD__ );
wfDebug( __METHOD__ . "($key)\n" );
+
$handle = $this->getReader();
if ( !$handle ) {
return null;
}
+
$val = dba_fetch( $key, $handle );
list( $val, $expiry ) = $this->decode( $val );
+
# Must close ASAP because locks are held
dba_close( $handle );
wfDebug( __METHOD__ . ": $key expired\n" );
$val = null;
}
+
wfProfileOut( __METHOD__ );
return $val;
}
function set( $key, $value, $exptime = 0 ) {
wfProfileIn( __METHOD__ );
wfDebug( __METHOD__ . "($key)\n" );
+
$blob = $this->encode( $value, $exptime );
+
$handle = $this->getWriter();
if ( !$handle ) {
return false;
}
+
$ret = dba_replace( $key, $blob, $handle );
dba_close( $handle );
+
wfProfileOut( __METHOD__ );
return $ret;
}
function delete( $key, $time = 0 ) {
wfProfileIn( __METHOD__ );
wfDebug( __METHOD__ . "($key)\n" );
+
$handle = $this->getWriter();
if ( !$handle ) {
return false;
}
+
$ret = dba_delete( $key, $handle );
dba_close( $handle );
+
wfProfileOut( __METHOD__ );
return $ret;
}
function add( $key, $value, $exptime = 0 ) {
wfProfileIn( __METHOD__ );
+
$blob = $this->encode( $value, $exptime );
+
$handle = $this->getWriter();
+
if ( !$handle ) {
return false;
}
+
$ret = dba_insert( $key, $blob, $handle );
+
# Insert failed, check to see if it failed due to an expired key
if ( !$ret ) {
list( $value, $expiry ) = $this->decode( dba_fetch( $key, $handle ) );
+
if ( $expiry < time() ) {
# Yes expired, delete and try again
dba_delete( $key, $handle );
}
dba_close( $handle );
+
wfProfileOut( __METHOD__ );
return $ret;
}
function keys() {
$reader = $this->getReader();
$k1 = dba_firstkey( $reader );
+
if ( !$k1 ) {
return array();
}
+
$result[] = $k1;
+
while ( $key = dba_nextkey( $reader ) ) {
$result[] = $key;
}
+
return $result;
}
}
*/
public function get( $key ) {
$val = wincache_ucache_get( $key );
- if ( is_string( $val ) )
+
+ if ( is_string( $val ) ) {
$val = unserialize( $val );
+ }
+
return $val;
}
*/
public function set( $key, $value, $expire = 0 ) {
wincache_ucache_set( $key, serialize( $value ), $expire );
+
return true;
}
*/
public function delete( $key, $time = 0 ) {
wincache_ucache_delete( $key );
+
return true;
}
$info = wincache_ucache_info();
$list = $info['ucache_entries'];
$keys = array();
+
foreach ( $list as $entry ) {
$keys[] = $entry['key_name'];
}
+
return $keys;
}
}
public static function newFromDB( $address, $user = 0, $killExpired = true ) {
$block = new Block;
$block->load( $address, $user, $killExpired );
+
if ( $block->isValid() ) {
return $block;
} else {
$res = $dbr->resultObject( $dbr->select( 'ipblocks', '*',
array( 'ipb_id' => $id ), __METHOD__ ) );
$block = new Block;
+
if ( $block->loadFromResult( $res ) ) {
return $block;
} else {
$db = wfGetDB( DB_SLAVE );
$options = array();
}
+
return $db;
}
if ( 0 == $user && $address === '' ) {
# Invalid user specification, not blocked
$this->clear();
+
return false;
}
if ( $user ) {
$res = $db->resultObject( $db->select( 'ipblocks', '*', array( 'ipb_user' => $user ),
__METHOD__, $options ) );
+
if ( $this->loadFromResult( $res, $killExpired ) ) {
return true;
}
if ( !$this->mCreateAccount ) {
$this->clear();
}
+
return false;
} else {
return true;
if ( !$this->mCreateAccount ) {
$this->clear();
}
+
return false;
} else {
return true;
}
}
$res->free();
+
return $ret;
}
$res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__, $options ) );
$success = $this->loadFromResult( $res, $killExpired );
+
return $success;
}
$dbw = wfGetDB( DB_MASTER );
$dbw->delete( 'ipblocks', array( 'ipb_id' => $this->mId ), __METHOD__ );
+
return $dbw->affectedRows() > 0;
}
*/
public function insert( $dbw = null ) {
wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" );
+
if ( $dbw === null )
$dbw = wfGetDB( DB_MASTER );
if ( !$this->mUser && $this->mAnonOnly ) {
$this->mBlockEmail = 0;
}
+
if ( !$this->mByName ) {
if ( $this->mBy ) {
$this->mByName = User::whoIs( $this->mBy );
wfDebug( "No IP found to retroactively autoblock\n" );
} else {
while ( $row = $dbr->fetchObject( $res ) ) {
- if ( $row->rc_ip )
+ if ( $row->rc_ip ) {
$this->doAutoblock( $row->rc_ip );
+ }
}
}
}
# exceed the user block. If it would exceed, then do nothing, else
# prolong block time
if ( $this->mExpiry &&
- ( $this->mExpiry < Block::getAutoblockExpiry( $ipblock->mTimestamp ) ) ) {
+ ( $this->mExpiry < Block::getAutoblockExpiry( $ipblock->mTimestamp ) )
+ ) {
return;
}
+
# Just update the timestamp
if ( !$justInserted ) {
$ipblock->updateTimestamp();
}
+
return;
} else {
$ipblock = new Block;
# Continue suppressing the name if needed
$ipblock->mHideName = $this->mHideName;
$ipblock->mAllowUsertalk = $this->mAllowUsertalk;
+
# If the user is already blocked with an expiry date, we don't
# want to pile on top of that!
if ( $this->mExpiry ) {
} else {
$ipblock->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp );
}
+
# Insert it
return $ipblock->insert();
}
*/
public function deleteIfExpired() {
wfProfileIn( __METHOD__ );
+
if ( $this->isExpired() ) {
wfDebug( "Block::deleteIfExpired() -- deleting\n" );
$this->delete();
wfDebug( "Block::deleteIfExpired() -- not expired\n" );
$retVal = false;
}
+
wfProfileOut( __METHOD__ );
return $retVal;
}
*/
public function isExpired() {
wfDebug( "Block::isExpired() checking current " . wfTimestampNow() . " vs $this->mExpiry\n" );
+
if ( !$this->mExpiry ) {
return false;
} else {
*/
public static function getAutoblockExpiry( $timestamp ) {
global $wgAutoblockExpiry;
+
return wfTimestamp( TS_MW, wfTimestamp( TS_UNIX, $timestamp ) + $wgAutoblockExpiry );
}
$range = "$newip/{$parts[1]}";
}
}
+
return $range;
}
if ( is_null( $msg ) ) {
$msg = array();
$keys = array( 'infiniteblock', 'expiringblock' );
+
foreach ( $keys as $key ) {
$msg[$key] = wfMsgHtml( $key );
}
$expiretimestr = htmlspecialchars( $wgLang->time( $expiry, true ) );
$expirystr = wfMsgReplaceArgs( $msg['expiringblock'], array( $expiredatestr, $expiretimestr ) );
}
+
return $expirystr;
}
return false;
}
}
+
return $expiry;
}
-
}
* than instantiating one of these objects directly.
* @ingroup Cache
*/
+
class DependencyWrapper {
var $value;
var $deps;
*/
function __construct( $value = false, $deps = array() ) {
$this->value = $value;
+
if ( !is_array( $deps ) ) {
$deps = array( $deps );
}
+
$this->deps = $deps;
}
return true;
}
}
+
return false;
}
$callbackParams = array(), $deps = array() )
{
$obj = $cache->get( $key );
+
if ( is_object( $obj ) && $obj instanceof DependencyWrapper && !$obj->isExpired() ) {
$value = $obj->value;
} elseif ( $callback ) {
} else {
$value = null;
}
+
return $value;
}
}
if ( !isset( $this->titleObj ) ) {
$this->titleObj = Title::makeTitle( $this->ns, $this->dbk );
}
+
return $this->titleObj;
}
foreach ( $this->getLinkBatch()->data as $ns => $dbks ) {
if ( count( $dbks ) > 0 ) {
$timestamps[$ns] = array();
+
foreach ( $dbks as $dbk => $value ) {
$timestamps[$ns][$dbk] = false;
}
$timestamps[$row->page_namespace][$row->page_title] = $row->page_touched;
}
}
+
return $timestamps;
}
function isExpired() {
$newTimestamps = $this->calculateTimestamps();
+
foreach ( $this->timestamps as $ns => $dbks ) {
foreach ( $dbks as $dbk => $oldTimestamp ) {
$newTimestamp = $newTimestamps[$ns][$dbk];
}
}
}
+
return false;
}
}