Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/152109

Change subject: SpecialUndelete/PageArchive: Use Config instead of globals
......................................................................

SpecialUndelete/PageArchive: Use Config instead of globals

Change-Id: Ic025412ed74d9cffad48a3ab04788d46ab43befb
---
M includes/api/ApiUndelete.php
M includes/specials/SpecialUndelete.php
M maintenance/undelete.php
3 files changed, 19 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/09/152109/1

diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php
index 7d6a7e4..3492972 100644
--- a/includes/api/ApiUndelete.php
+++ b/includes/api/ApiUndelete.php
@@ -56,7 +56,7 @@
                        $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'],
diff --git a/includes/specials/SpecialUndelete.php 
b/includes/specials/SpecialUndelete.php
index 25f520e..8acf8a2 100644
--- a/includes/specials/SpecialUndelete.php
+++ b/includes/specials/SpecialUndelete.php
@@ -36,11 +36,19 @@
        /** @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;
        }
 
        /**
@@ -115,8 +123,6 @@
         * @return ResultWrapper
         */
        function listRevisions() {
-               global $wgContentHandlerUseDB;
-
                $dbr = wfGetDB( DB_SLAVE );
 
                $tables = array( 'archive' );
@@ -126,7 +132,7 @@
                        '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';
                }
@@ -190,8 +196,6 @@
         * @return Revision|null
         */
        function getRevision( $timestamp ) {
-               global $wgContentHandlerUseDB;
-
                $dbr = wfGetDB( DB_SLAVE );
 
                $fields = array(
@@ -209,7 +213,7 @@
                        'ar_sha1',
                );
 
-               if ( $wgContentHandlerUseDB ) {
+               if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
                        $fields[] = 'ar_content_format';
                        $fields[] = 'ar_content_model';
                }
@@ -442,8 +446,6 @@
         * @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();
                }
@@ -516,7 +518,7 @@
                        'ar_sha1'
                );
 
-               if ( $wgContentHandlerUseDB ) {
+               if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
                        $fields[] = 'ar_content_format';
                        $fields[] = 'ar_content_model';
                }
@@ -806,12 +808,10 @@
        }
 
        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(
@@ -891,7 +891,7 @@
                        return;
                }
 
-               $archive = new PageArchive( $this->mTargetObj );
+               $archive = new PageArchive( $this->mTargetObj, 
$this->getConfig() );
                if ( !wfRunHooks( 'UndeleteForm::showRevision', array( 
&$archive, $this->mTargetObj ) ) ) {
                        return;
                }
@@ -1198,7 +1198,7 @@
                        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();
@@ -1610,9 +1610,7 @@
        }
 
        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' );
                }
 
@@ -1621,7 +1619,7 @@
                }
 
                $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,
diff --git a/maintenance/undelete.php b/maintenance/undelete.php
index c890c69..adebd27 100644
--- a/maintenance/undelete.php
+++ b/maintenance/undelete.php
@@ -47,7 +47,7 @@
                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" );

-- 
To view, visit https://gerrit.wikimedia.org/r/152109
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic025412ed74d9cffad48a3ab04788d46ab43befb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to