/** @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,