MaxSem has uploaded a new change for review.

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

Change subject: Minor fixes
......................................................................

Minor fixes

* Annotations
* Deprecated functions
* Namespace tests

Change-Id: I521f6af6074a454cec5322ab4cd46db08350c2c3
---
M includes/ApiQueryExtracts.php
M includes/ExtractFormatter.php
M includes/Hooks.php
M tests/phpunit/ExtractFormatterTest.php
4 files changed, 14 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TextExtracts 
refs/changes/47/312447/1

diff --git a/includes/ApiQueryExtracts.php b/includes/ApiQueryExtracts.php
index e704cef..0fe7a86 100644
--- a/includes/ApiQueryExtracts.php
+++ b/includes/ApiQueryExtracts.php
@@ -22,8 +22,8 @@
 use ApiMain;
 use ApiQueryBase;
 use Config;
-use ConfigFactory;
 use FauxRequest;
+use MediaWiki\MediaWikiServices;
 use MWTidy;
 use ParserCache;
 use ParserOptions;
@@ -131,7 +131,7 @@
                }
                if ( $text === false ) {
                        $text = $this->parse( $page );
-                       $text = $this->convertText( $text, $title, 
$this->params['plaintext'] );
+                       $text = $this->convertText( $text );
                        $this->setCache( $page, $text );
                }
                return $text;
@@ -238,7 +238,7 @@
         * @return ApiQueryExtracts
         */
        public static function factory( $query, $action ) {
-               $config = ConfigFactory::getDefaultInstance()->makeConfig( 
'textextracts' );
+               $config = 
MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 
'textextracts' );
                return new self( $query, $action, $config );
        }
 
diff --git a/includes/ExtractFormatter.php b/includes/ExtractFormatter.php
index 30a88f0..3f1c4af 100644
--- a/includes/ExtractFormatter.php
+++ b/includes/ExtractFormatter.php
@@ -3,6 +3,7 @@
 namespace TextExtracts;
 
 use Config;
+use DOMElement;
 use HtmlFormatter\HtmlFormatter;
 use Exception;
 
@@ -136,6 +137,7 @@
                $doc = $this->getDoc();
                $spans = $doc->getElementsByTagName( 'span' );
 
+               /** @var DOMElement $span */
                foreach ( $spans as $span ) {
                        $span->removeAttribute( 'class' );
                        $span->removeAttribute( 'style' );
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 7aabce2..36f8905 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -4,8 +4,8 @@
 
 use ApiMain;
 use ApiResult;
-use ConfigFactory;
 use FauxRequest;
+use MediaWiki\MediaWikiServices;
 
 class Hooks {
 
@@ -15,7 +15,7 @@
         * @return bool
         */
        public static function onApiOpenSearchSuggest( &$results ) {
-               $config = ConfigFactory::getDefaultInstance()->makeConfig( 
'textextracts' );
+               $config = 
MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 
'textextracts' );
                if ( !$config->get( 'ExtractsExtendOpenSearchXml' ) || !count( 
$results ) ) {
                        return true;
                }
diff --git a/tests/phpunit/ExtractFormatterTest.php 
b/tests/phpunit/ExtractFormatterTest.php
index 07366e8..c633fb3 100644
--- a/tests/phpunit/ExtractFormatterTest.php
+++ b/tests/phpunit/ExtractFormatterTest.php
@@ -1,4 +1,10 @@
 <?php
+
+namespace TextExtracts\Test;
+
+use MediaWiki\MediaWikiServices;
+use MediaWikiTestCase;
+use ParserOptions;
 use TextExtracts\ExtractFormatter;
 
 /**
@@ -9,10 +15,9 @@
         * @dataProvider provideExtracts
         */
        public function testExtracts( $expected, $text, $plainText ) {
-               $title = Title::newFromText( 'Test' );
                $po = new ParserOptions();
                $po->setEditSection( true );
-               $config = ConfigFactory::getDefaultInstance()->makeConfig( 
'textextracts' );
+               $config = 
MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 
'textextracts' );
                $fmt = new ExtractFormatter( $text, $plainText, $config );
                $fmt->remove( '.metadata' ); // Will be added via 
$wgExtractsRemoveClasses on WMF
                $text = trim( $fmt->getText() );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I521f6af6074a454cec5322ab4cd46db08350c2c3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TextExtracts
Gerrit-Branch: master
Gerrit-Owner: MaxSem <maxsem.w...@gmail.com>

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

Reply via email to