public function execute() {
$params = $this->extractRequestParams();
+ $activeUserDays = $this->getConfig()->get( 'ActiveUserDays' );
if ( $params['activeusers'] ) {
// Update active user cache
- SpecialActiveUsers::mergeActiveUsers( 600 );
+ SpecialActiveUsers::mergeActiveUsers( 600, $activeUserDays );
}
$db = $this->getDB();
}
if ( $params['activeusers'] ) {
- $activeUserSeconds = $this->getConfig()->get( 'ActiveUserDays' ) * 86400;
+ $activeUserSeconds = $activeUserDays * 86400;
// Filter query to only include users in the active users cache
$this->addTables( 'querycachetwo' );
$params['timestamps'][$i] = wfTimestamp( TS_MW, $ts );
}
- $pa = new PageArchive( $titleObj );
+ $pa = new PageArchive( $titleObj, $this->getConfig() );
$retval = $pa->undelete(
( isset( $params['timestamps'] ) ? $params['timestamps'] : array() ),
$params['reason'],
* @param string $par Parameter passed to the page
*/
function __construct( IContextSource $context = null, $group = null, $par = null ) {
- global $wgActiveUserDays;
-
parent::__construct( $context );
- $this->RCMaxAge = $wgActiveUserDays;
+ $this->RCMaxAge = $this->getConfig()->get( 'ActiveUserDays' );
$un = $this->getRequest()->getText( 'username', $par );
$this->requestedUser = '';
if ( $un != '' ) {
}
function getPageHeader() {
- global $wgScript;
-
$self = $this->getTitle();
$limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : '';
# Form tag
- $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
+ $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => wfScript() ) );
$out .= Xml::fieldset( $this->msg( 'activeusers' )->text() ) . "\n";
$out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n";
* @param string $par Parameter passed to the page or null
*/
public function execute( $par ) {
- global $wgActiveUserDays;
+ $days = $this->getConfig()->get( 'ActiveUserDays' );
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->wrapWikiMsg( "<div class='mw-activeusers-intro'>\n$1\n</div>",
- array( 'activeusers-intro', $this->getLanguage()->formatNum( $wgActiveUserDays ) ) );
+ array( 'activeusers-intro', $this->getLanguage()->formatNum( $days ) ) );
// Occasionally merge in new updates
- $seconds = min( self::mergeActiveUsers( 600 ), $wgActiveUserDays * 86400 );
+ $seconds = min( self::mergeActiveUsers( 600, $days ), $days * 86400 );
// Mention the level of staleness
$out->addWikiMsg( 'cachedspecial-viewing-cached-ttl',
$this->getLanguage()->formatDuration( $seconds ) );
}
/**
- * @param intr $period Seconds (do updates no more often than this)
+ * @param int $period Seconds (do updates no more often than this)
+ * @param int $days How many days user must be idle before he is considered inactive
* @return int How many seconds old the cache is
*/
- public static function mergeActiveUsers( $period ) {
- global $wgActiveUserDays;
-
+ public static function mergeActiveUsers( $period, $days ) {
$dbr = wfGetDB( DB_SLAVE );
$cTime = $dbr->selectField( 'querycache_info',
'qci_timestamp',
if ( !$cTime || ( time() - wfTimestamp( TS_UNIX, $cTime ) ) > $period ) {
$dbw = wfGetDB( DB_MASTER );
if ( $dbw->estimateRowCount( 'recentchanges' ) <= 10000 ) {
- $window = $wgActiveUserDays * 86400; // small wiki
+ $window = $days * 86400; // small wiki
} else {
$window = $period * 2;
}
- $cTime = self::doQueryCacheUpdate( $dbw, $window ) ?: $cTime;
+ $cTime = self::doQueryCacheUpdate( $dbw, $days, $window ) ?: $cTime;
}
}
return ( time() -
- ( $cTime ? wfTimestamp( TS_UNIX, $cTime ) : $wgActiveUserDays * 86400 ) );
+ ( $cTime ? wfTimestamp( TS_UNIX, $cTime ) : $days * 86400 ) );
}
/**
public static function cacheUpdate( DatabaseBase $dbw ) {
global $wgActiveUserDays;
- self::doQueryCacheUpdate( $dbw, $wgActiveUserDays * 86400 );
+ self::doQueryCacheUpdate( $dbw, $wgActiveUserDays, $wgActiveUserDays * 86400 );
}
/**
* Update the query cache as needed
*
* @param DatabaseBase $dbw
+ * @param int $days How many days user must be idle before he is considered inactive
* @param int $window Maximum time range of new data to scan (in seconds)
* @return int|bool UNIX timestamp the cache is now up-to-date as of (false on error)
*/
- protected static function doQueryCacheUpdate( DatabaseBase $dbw, $window ) {
- global $wgActiveUserDays;
-
+ protected static function doQueryCacheUpdate( DatabaseBase $dbw, $days, $window ) {
$lockKey = wfWikiID() . '-activeusers';
if ( !$dbw->lock( $lockKey, __METHOD__, 1 ) ) {
return false; // exclusive update (avoids duplicate entries)
// Pick the date range to fetch from. This is normally from the last
// update to till the present time, but has a limited window for sanity.
// If the window is limited, multiple runs are need to fully populate it.
- $sTimestamp = max( $cTimeUnix, $now - $wgActiveUserDays * 86400 );
+ $sTimestamp = max( $cTimeUnix, $now - $days * 86400 );
$eTimestamp = min( $sTimestamp + $window, $now );
// Get all the users active since the last update
$dbw->delete( 'querycachetwo',
array(
'qcc_type' => 'activeusers',
- 'qcc_value < ' . $dbw->addQuotes( $now - $wgActiveUserDays * 86400 ) // TS_UNIX
+ 'qcc_value < ' . $dbw->addQuotes( $now - $days * 86400 ) // TS_UNIX
),
__METHOD__
);
$size = $request->getIntOrNull( 'size' );
$NS = $request->getIntOrNull( 'namespace' );
- $pager = new ProtectedTitlesPager( $this, array(), $type, $level, $NS, $sizetype, $size );
+ $pager = new ProtectedTitlesPager( $this->getContext(), array(), $type, $level, $NS, $sizetype, $size );
$this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level ) );
* @private
*/
function showOptions( $namespace, $type = 'edit', $level ) {
- global $wgScript;
- $action = htmlspecialchars( $wgScript );
+ $action = htmlspecialchars( wfScript() );
$title = $this->getPageTitle();
$special = htmlspecialchars( $title->getPrefixedDBkey() );
* @private
*/
function getLevelMenu( $pr_level ) {
- global $wgRestrictionLevels;
-
// Temporary array
$m = array( $this->msg( 'restriction-level-all' )->text() => 0 );
$options = array();
// First pass to load the log names
- foreach ( $wgRestrictionLevels as $type ) {
+ foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) {
if ( $type != '' && $type != '*' ) {
// Messages: restriction-level-sysop, restriction-level-autoconfirmed
$text = $this->msg( "restriction-level-$type" )->text();
}
public function execute( $par ) {
- global $wgMemc, $wgDisableCounters, $wgMiserMode;
+ global $wgMemc;
+
+ $disableCounters = $this->getConfig()->get( 'DisableCounters' );
+ $miserMode = $this->getConfig()->get( 'MiserMode' );
$this->setHeaders();
$this->getOutput()->addModuleStyles( 'mediawiki.special' );
# Staticic - views
$viewsStats = '';
- if ( !$wgDisableCounters ) {
+ if ( !$disableCounters ) {
$viewsStats = $this->getViewsStats();
}
# Set active user count
- if ( !$wgMiserMode ) {
+ if ( !$miserMode ) {
$key = wfMemcKey( 'sitestats', 'activeusers-updated' );
// Re-calculate the count if the last tally is old...
if ( !$wgMemc->get( $key ) ) {
$text .= $viewsStats;
# Statistic - popular pages
- if ( !$wgDisableCounters && !$wgMiserMode ) {
+ if ( !$disableCounters && !$miserMode ) {
$text .= $this->getMostViewedPages();
}
}
private function getUserStats() {
- global $wgActiveUserDays;
-
return Xml::openElement( 'tr' ) .
Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-users' )->parse() ) .
Xml::closeElement( 'tr' ) .
$this->getLanguage()->formatNum( $this->activeUsers ),
array( 'class' => 'mw-statistics-users-active' ),
'statistics-users-active-desc',
- $this->getLanguage()->formatNum( $wgActiveUserDays )
+ $this->getLanguage()->formatNum( $this->getConfig()->get( 'ActiveUserDays' ) )
);
}
private function getGroupStats() {
- global $wgGroupPermissions, $wgImplicitGroups;
$text = '';
- foreach ( $wgGroupPermissions as $group => $permissions ) {
+ foreach ( $this->getConfig()->get( 'GroupPermissions' ) as $group => $permissions ) {
# Skip generic * and implicit groups
- if ( in_array( $group, $wgImplicitGroups ) || $group == '*' ) {
+ if ( in_array( $group, $this->getConfig()->get( 'ImplicitGroups' ) ) || $group == '*' ) {
continue;
}
$groupname = htmlspecialchars( $group );
}
function execute( $par ) {
- // Global array containing names of tracking categories
- global $wgTrackingCategories;
-
$this->setHeaders();
$this->outputHeader();
$this->getOutput()->allowClickjacking();
</tr></thead>"
);
- foreach ( $wgTrackingCategories as $catMsg ) {
+ foreach ( $this->getConfig()->get( 'TrackingCategories' ) as $catMsg ) {
/*
* Check if the tracking category varies by namespace
* Otherwise only pages in the current namespace will be displayed
/** @var Status */
protected $revisionStatus;
- function __construct( $title ) {
+ /** @var Config */
+ protected $config;
+
+ function __construct( $title, Config $config = null ) {
if ( is_null( $title ) ) {
throw new MWException( __METHOD__ . ' given a null title.' );
}
$this->title = $title;
+ if ( $config === null ) {
+ wfDebug( __METHOD__ . ' did not have a Config object passed to it' );
+ $config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+ }
+ $this->config = $config;
}
/**
* @return ResultWrapper
*/
function listRevisions() {
- global $wgContentHandlerUseDB;
-
$dbr = wfGetDB( DB_SLAVE );
$tables = array( 'archive' );
'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1',
);
- if ( $wgContentHandlerUseDB ) {
+ if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
$fields[] = 'ar_content_format';
$fields[] = 'ar_content_model';
}
* @return Revision|null
*/
function getRevision( $timestamp ) {
- global $wgContentHandlerUseDB;
-
$dbr = wfGetDB( DB_SLAVE );
$fields = array(
'ar_sha1',
);
- if ( $wgContentHandlerUseDB ) {
+ if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
$fields[] = 'ar_content_format';
$fields[] = 'ar_content_model';
}
* @return Status Status object containing the number of revisions restored on success
*/
private function undeleteRevisions( $timestamps, $unsuppress = false, $comment = '' ) {
- global $wgContentHandlerUseDB;
-
if ( wfReadOnly() ) {
throw new ReadOnlyError();
}
'ar_sha1'
);
- if ( $wgContentHandlerUseDB ) {
+ if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
$fields[] = 'ar_content_format';
$fields[] = 'ar_content_model';
}
}
function showSearchForm() {
- global $wgScript;
-
$out = $this->getOutput();
$out->setPageTitle( $this->msg( 'undelete-search-title' ) );
$out->addHTML(
- Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
+ Xml::openElement( 'form', array( 'method' => 'get', 'action' => wfScript() ) ) .
Xml::fieldset( $this->msg( 'undelete-search-box' )->text() ) .
Html::hidden( 'title', $this->getPageTitle()->getPrefixedDBkey() ) .
Html::rawElement(
return;
}
- $archive = new PageArchive( $this->mTargetObj );
+ $archive = new PageArchive( $this->mTargetObj, $this->getConfig() );
if ( !wfRunHooks( 'UndeleteForm::showRevision', array( &$archive, $this->mTargetObj ) ) ) {
return;
}
array( 'undeletepagetitle', wfEscapeWikiText( $this->mTargetObj->getPrefixedText() ) )
);
- $archive = new PageArchive( $this->mTargetObj );
+ $archive = new PageArchive( $this->mTargetObj, $this->getConfig() );
wfRunHooks( 'UndeleteForm::showHistory', array( &$archive, $this->mTargetObj ) );
/*
$text = $archive->getLastRevisionText();
}
function undelete() {
- global $wgUploadMaintenance;
-
- if ( $wgUploadMaintenance && $this->mTargetObj->getNamespace() == NS_FILE ) {
+ if ( $this->getConfig()->get( 'UploadMaintenance' ) && $this->mTargetObj->getNamespace() == NS_FILE ) {
throw new ErrorPageError( 'undelete-error', 'filedelete-maintenance' );
}
}
$out = $this->getOutput();
- $archive = new PageArchive( $this->mTargetObj );
+ $archive = new PageArchive( $this->mTargetObj, $this->getConfig() );
wfRunHooks( 'UndeleteForm::undelete', array( &$archive, $this->mTargetObj ) );
$ok = $archive->undelete(
$this->mTargetTimestamp,
}
function getQueryInfo() {
- global $wgWantedPagesThreshold;
- $count = $wgWantedPagesThreshold - 1;
+ $count = $this->getConfig()->get( 'WantedPagesThreshold' ) - 1;
$query = array(
'tables' => array(
'pagelinks',
if ( !$wgUser ) {
$this->error( "Invalid username", true );
}
- $archive = new PageArchive( $title );
+ $archive = new PageArchive( $title, RequestContext::getMain()->getConfig() );
$this->output( "Undeleting " . $title->getPrefixedDBkey() . '...' );
$archive->undelete( array(), $reason );
$this->output( "done\n" );
/**
* Display a notification message to the user.
*
- * @param {HTMLElement|jQuery|mw.Message|string} message
+ * @param {HTMLElement|HTMLElement[]|jQuery|mw.Message|string} message
* @param {Object} options The options to use for the notification.
* See #defaults for details.
* @return {mw.Notification} Notification object