mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-09-01 05:56:56 +02:00
Upgrade to use of new MediaWiki\Title for use in MW 1.44
This commit is contained in:
@@ -64,7 +64,7 @@ class Extension {
|
|||||||
// MW 1.36+
|
// MW 1.36+
|
||||||
if ( method_exists( MediaWikiServices::class, 'getWikiPageFactory' ) ) {
|
if ( method_exists( MediaWikiServices::class, 'getWikiPageFactory' ) ) {
|
||||||
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
|
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
|
||||||
$wikiPage = $wikiPageFactory->newFromTitle( $title );
|
$wikiPage = $wikiPageFactory->newFromLinkTarget( $title );
|
||||||
} else {
|
} else {
|
||||||
$wikiPage = WikiPage::factory( $title );
|
$wikiPage = WikiPage::factory( $title );
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
namespace LinkTitles;
|
namespace LinkTitles;
|
||||||
|
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
|
use MediaWiki\Title\Title as MWTitle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a page that is a potential link target.
|
* Represents a page that is a potential link target.
|
||||||
@@ -32,7 +33,7 @@ use MediaWiki\MediaWikiServices;
|
|||||||
class Target {
|
class Target {
|
||||||
/**
|
/**
|
||||||
* A Title object for the target page currently being examined.
|
* A Title object for the target page currently being examined.
|
||||||
* @var \Title $title
|
* @var MediaWiki\Title\Title $title
|
||||||
*/
|
*/
|
||||||
private $title;
|
private $title;
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ class Target {
|
|||||||
* @param String &$title Title of the target page
|
* @param String &$title Title of the target page
|
||||||
*/
|
*/
|
||||||
public function __construct( $namespace, $title, Config &$config ) {
|
public function __construct( $namespace, $title, Config &$config ) {
|
||||||
$this->title = \Title::makeTitleSafe( $namespace, $title );
|
$this->title = MWTitle::makeTitleSafe( $namespace, $title );
|
||||||
$this->titleValue = $this->title->getTitleValue();
|
$this->titleValue = $this->title->getTitleValue();
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
|
||||||
|
@@ -24,6 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
namespace LinkTitles;
|
namespace LinkTitles;
|
||||||
|
|
||||||
|
use MediaWiki\MediaWikiServices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches potential target page titles from the database.
|
* Fetches potential target page titles from the database.
|
||||||
*/
|
*/
|
||||||
@@ -41,7 +43,7 @@ class Targets {
|
|||||||
* @param String $sourceNamespace The namespace of the current page.
|
* @param String $sourceNamespace The namespace of the current page.
|
||||||
* @param Config $config LinkTitles configuration.
|
* @param Config $config LinkTitles configuration.
|
||||||
*/
|
*/
|
||||||
public static function singleton( \Title $title, Config $config ) {
|
public static function singleton( \MediaWiki\Title\Title $title, Config $config ) {
|
||||||
if ( ( self::$instance === null ) || ( self::$instance->sourceNamespace != $title->getNamespace() ) ) {
|
if ( ( self::$instance === null ) || ( self::$instance->sourceNamespace != $title->getNamespace() ) ) {
|
||||||
self::$instance = new Targets( $title, $config );
|
self::$instance = new Targets( $title, $config );
|
||||||
}
|
}
|
||||||
@@ -83,7 +85,7 @@ class Targets {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor is private to enforce using the singleton pattern.
|
* The constructor is private to enforce using the singleton pattern.
|
||||||
* @param \Title $title
|
* @param Mediawiki\Title\Title $title
|
||||||
*/
|
*/
|
||||||
private function __construct( \Title $title, Config $config) {
|
private function __construct( \Title $title, Config $config) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
@@ -135,7 +137,7 @@ class Targets {
|
|||||||
// shortest to longest. Only titles from 'normal' pages (namespace uid
|
// shortest to longest. Only titles from 'normal' pages (namespace uid
|
||||||
// = 0) are returned. Since the db may be sqlite, we need a try..catch
|
// = 0) are returned. Since the db may be sqlite, we need a try..catch
|
||||||
// structure because sqlite does not support the CHAR_LENGTH function.
|
// structure because sqlite does not support the CHAR_LENGTH function.
|
||||||
$dbr = wfGetDB( DB_REPLICA );
|
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA );
|
||||||
$this->queryResult = $dbr->select(
|
$this->queryResult = $dbr->select(
|
||||||
'page',
|
'page',
|
||||||
array( 'page_title', 'page_namespace' , "weight" => $weightSelect),
|
array( 'page_title', 'page_namespace' , "weight" => $weightSelect),
|
||||||
|
@@ -26,8 +26,8 @@
|
|||||||
*
|
*
|
||||||
* @group bovender
|
* @group bovender
|
||||||
*/
|
*/
|
||||||
class SplitterTest extends \MediaWikiTestCase
|
|
||||||
{
|
class SplitterTest extends LinkTitles\TestCase {
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideSplitData
|
* @dataProvider provideSplitData
|
||||||
*/
|
*/
|
||||||
|
@@ -24,8 +24,8 @@
|
|||||||
/**
|
/**
|
||||||
* @group bovender
|
* @group bovender
|
||||||
*/
|
*/
|
||||||
class TargetTest extends \MediaWikiTestCase
|
|
||||||
{
|
class TargetTest extends LinkTitles\TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideStartOnly
|
* @dataProvider provideStartOnly
|
||||||
|
@@ -21,8 +21,9 @@
|
|||||||
* @author Daniel Kraus <bovender@bovender.de>
|
* @author Daniel Kraus <bovender@bovender.de>
|
||||||
*/
|
*/
|
||||||
namespace LinkTitles;
|
namespace LinkTitles;
|
||||||
|
use MediaWikiIntegrationTestCase;
|
||||||
|
|
||||||
abstract class TestCase extends \MediaWikiTestCase {
|
abstract class TestCase extends MediaWikiIntegrationTestCase {
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
Reference in New Issue
Block a user