Compare commits

...

6 Commits

Author SHA1 Message Date
b55f6ea5c1 Fixing for new MediaWiki Titles 2025-07-06 23:21:53 +02:00
9ec3c49f50 Fixing for new MediaWiki Titles 2025-07-06 23:20:44 +02:00
255a5ca9a8 Merge pull request #1 from hallowelt/main
Replace deprecated wfGetDB
2025-07-06 23:17:30 +02:00
05030e02ba more testing for new mediawiki titles 2025-07-06 22:49:16 +02:00
87de424161 Testing old and new title fix 2025-07-06 22:44:30 +02:00
hslater
e4432c18b2 Replace deprecated wfGetDB
Prevents
PHP Deprecated:  Use of wfGetDB was deprecated in MediaWiki 1.39
when running update.php

Compatible with MW 1.35.0
2025-03-05 20:07:45 +13:00
2 changed files with 9 additions and 7 deletions

View File

@@ -25,14 +25,14 @@
namespace LinkTitles;
use MediaWiki\MediaWikiServices;
use MediaWiki\Title\Title as MWTitle;
/**
* Represents a page that is a potential link target.
*/
class Target {
/**
* A Title object for the target page currently being examined.
* @var \Title $title
* @var MediaWiki\Title\Title $title
*/
private $title;
@@ -76,7 +76,7 @@ class Target {
* @param String &$title Title of the target page
*/
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->config = $config;

View File

@@ -24,6 +24,8 @@
*/
namespace LinkTitles;
use MediaWiki\MediaWikiServices;
/**
* Fetches potential target page titles from the database.
*/
@@ -41,7 +43,7 @@ class Targets {
* @param String $sourceNamespace The namespace of the current page.
* @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() ) ) {
self::$instance = new Targets( $title, $config );
}
@@ -83,9 +85,9 @@ class Targets {
/**
* 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( \MediaWiki\Title\Title $title, Config $config) {
$this->config = $config;
$this->sourceNamespace = $title->getNamespace();
$this->fetch();
@@ -135,7 +137,7 @@ class Targets {
// shortest to longest. Only titles from 'normal' pages (namespace uid
// = 0) are returned. Since the db may be sqlite, we need a try..catch
// 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(
'page',
array( 'page_title', 'page_namespace' , "weight" => $weightSelect),