Minor fixes

* Annotations
* Deprecated functions
* Namespace tests

Change-Id: I521f6af6074a454cec5322ab4cd46db08350c2c3
This commit is contained in:
Max Semenik 2016-09-22 18:51:12 -07:00
parent 754c9e4f19
commit 264f65215b
4 changed files with 14 additions and 7 deletions

View file

@ -22,8 +22,8 @@ use ApiBase;
use ApiMain;
use ApiQueryBase;
use Config;
use ConfigFactory;
use FauxRequest;
use MediaWiki\MediaWikiServices;
use MWTidy;
use ParserCache;
use ParserOptions;
@ -131,7 +131,7 @@ class ApiQueryExtracts extends ApiQueryBase {
}
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 @@ class ApiQueryExtracts extends ApiQueryBase {
* @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 );
}

View file

@ -3,6 +3,7 @@
namespace TextExtracts;
use Config;
use DOMElement;
use HtmlFormatter\HtmlFormatter;
use Exception;
@ -136,6 +137,7 @@ class ExtractFormatter extends HtmlFormatter {
$doc = $this->getDoc();
$spans = $doc->getElementsByTagName( 'span' );
/** @var DOMElement $span */
foreach ( $spans as $span ) {
$span->removeAttribute( 'class' );
$span->removeAttribute( 'style' );

View file

@ -4,8 +4,8 @@ namespace TextExtracts;
use ApiMain;
use ApiResult;
use ConfigFactory;
use FauxRequest;
use MediaWiki\MediaWikiServices;
class Hooks {
@ -15,7 +15,7 @@ class Hooks {
* @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;
}

View file

@ -1,4 +1,10 @@
<?php
namespace TextExtracts\Test;
use MediaWiki\MediaWikiServices;
use MediaWikiTestCase;
use ParserOptions;
use TextExtracts\ExtractFormatter;
/**
@ -9,10 +15,9 @@ class ExtractFormatterTest extends MediaWikiTestCase {
* @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() );