Skip to content

Commit 600f520

Browse files
alistair3149paladoxhuaj1ng
authored
Update MW class imports and methods (SemanticMediaWiki#6172)
* Fix missing parameters in runLocalMessageCopy * Fix incorrect schemaList fallback behavior * Update class imports Co-authored-by: paladox <thomasmulhall410@yahoo.com> * Avoid creating test user on Intergration test setup * Remove redundant call of $db->tableName() Fixes: SemanticMediaWiki#6150 Co-authored-by: alistair3149 <alistair3149@users.noreply.github.com> * Add missing class import * Fix various issues raised from CI * Fix ArticleFromTitleTest * Test MW 1.44 with PHP 8.3 * Simplify isCreatorLastEditor comparsion UserId is good enough for comparison. * Partial revert changes in isCreatorLastEditor Co-authored-by: paladox <thomasmulhall410@yahoo.com> * Fix missing namespaces * Add missing classes in tests * Use namespaced class for mock * Mark MariaDb 11.8 as experimental Many of the DB test failures might be related to MariaDB 11.8, updating the CI to test for that * Mark PHP 8.3 test as experimental * Fix incorrect article path in tests * Skip various broken tests There are a few tests that are broken due to changes from 1.39 to 1.43. We should skip them for now until we can fix them. --------- Co-authored-by: paladox <thomasmulhall410@yahoo.com> Co-authored-by: Hua <75751972+huaj1ng@users.noreply.github.com>
1 parent b2dd8cc commit 600f520

611 files changed

Lines changed: 2060 additions & 1904 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,23 @@ jobs:
2525
- mediawiki_version: '1.43'
2626
php_version: 8.2
2727
database_type: mysql
28-
database_image: "mariadb:11.8"
28+
database_image: "mariadb:11.2"
2929
coverage: false
3030
experimental: false
31+
- mediawiki_version: '1.43'
32+
php_version: 8.3
33+
database_type: mysql
34+
database_image: "mariadb:11.2"
35+
coverage: false
36+
experimental: true
3137
- mediawiki_version: '1.44'
32-
php_version: 8.2
38+
php_version: 8.3
39+
database_type: mysql
40+
database_image: "mariadb:11.2"
41+
coverage: false
42+
experimental: true
43+
- mediawiki_version: '1.44'
44+
php_version: 8.3
3345
database_type: mysql
3446
database_image: "mariadb:11.8"
3547
coverage: false

docs/examples/boilerplate.resultprinter.example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace SMW\Query\ResultPrinters;
88
use SMW\Query\QueryResult;
99
use SMWDataItem as DataItem;
1010
use SMWDataValue as DataValue;
11-
use Html;
11+
use MediaWiki\Html\Html;
1212

1313
/**
1414
* Boilerplate query printer

docs/examples/hook.pagecontentsavecomplete.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
```php
77
use MediaWiki\MediaWikiServices;
8-
use ParserOutput;
8+
use MediaWiki\Parser\ParserOutput;
99
use SMW\Services\ServicesFactory as ApplicationFactory;
1010
use SMW\DataModel\ContainerSemanticData;
1111
use SMW\DataValueFactory;

includes/ContentParser.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
namespace SMW;
44

5+
use MediaWiki\Context\RequestContext;
56
use MediaWiki\MediaWikiServices;
7+
use MediaWiki\Parser\Parser;
8+
use MediaWiki\Parser\ParserOptions;
69
use MediaWiki\Revision\RevisionRecord;
710
use MediaWiki\Revision\SlotRecord;
8-
use Parser;
9-
use ParserOptions;
10-
use RequestContext;
11+
use MediaWiki\Title\Title;
1112
use SMW\MediaWiki\RevisionGuardAwareTrait;
12-
use Title;
13-
use User;
1413

1514
/**
1615
* Fetches the ParserOutput either by parsing an invoked text component,
@@ -188,7 +187,7 @@ private function makeParserOptions() {
188187
if ( $this->getRevision() !== null ) {
189188
$identity = $this->getRevision()->getUser();
190189
if ( $identity ) {
191-
$user = User::newFromIdentity( $identity );
190+
$user = MediaWikiServices::getInstance()->getUserFactory()->newFromUserIdentity( $identity );
192191
}
193192
}
194193

includes/GlobalFunctions.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<?php
22

3+
use MediaWiki\Linker\Linker;
4+
use MediaWiki\Parser\Sanitizer;
5+
use MediaWiki\WikiMap\WikiMap;
36
use SMW\ConfigPreloader;
47
use SMW\DataValues\Number\IntlNumberFormatter;
58
use SMW\Highlighter;
9+
use SMW\Localizer\Localizer;
610
use SMW\Localizer\LocalLanguage\LocalLanguage;
711
use SMW\ProcessingErrorMsgHandler;
12+
use SMW\Store;
13+
use SMW\StoreFactory;
814

915
/**
1016
* Global functions specified and used by Semantic MediaWiki. In general, it is
@@ -145,10 +151,10 @@ function smwfEncodeMessages( array $messages, $type = 'warning', $separator = '
145151
/**
146152
* Returns an instance for the storage back-end
147153
*
148-
* @return \SMW\Store
154+
* @return Store
149155
*/
150156
function &smwfGetStore() {
151-
$store = \SMW\StoreFactory::getStore();
157+
$store = StoreFactory::getStore();
152158
return $store;
153159
}
154160

@@ -161,13 +167,8 @@ function &smwfGetStore() {
161167
* @return string
162168
*/
163169
function smwfCacheKey( $namespace, $key ) {
164-
if ( version_compare( MW_VERSION, '1.40', '<' ) ) {
165-
$cachePrefix = $GLOBALS['wgCachePrefix'] === false ?
166-
WikiMap::getCurrentWikiId() : $GLOBALS['wgCachePrefix'];
167-
} else {
168-
$cachePrefix = $GLOBALS['wgCachePrefix'] === false ?
169-
MediaWiki\WikiMap\WikiMap::getCurrentWikiId() : $GLOBALS['wgCachePrefix'];
170-
}
170+
$cachePrefix = $GLOBALS['wgCachePrefix'] === false ?
171+
WikiMap::getCurrentWikiId() : $GLOBALS['wgCachePrefix'];
171172

172173
if ( $namespace[0] !== ':' ) {
173174
$namespace = ':' . $namespace;
@@ -196,11 +197,7 @@ function smwfGetLinker() {
196197
static $linker = false;
197198

198199
if ( $linker === false ) {
199-
if ( version_compare( MW_VERSION, '1.40', '<' ) ) {
200-
$linker = new Linker();
201-
} else {
202-
$linker = new MediaWiki\Linker\Linker();
203-
}
200+
$linker = new Linker();
204201
}
205202

206203
return $linker;

includes/Highlighter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace SMW;
44

5-
use Html;
5+
use MediaWiki\Html\Html;
66
use SMW\Localizer\Message;
77
use SMWOutputs;
88

includes/SMW_Infolink.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use MediaWiki\Linker\Linker;
4+
use MediaWiki\MediaWikiServices;
35
use SMW\Localizer\Localizer;
46
use SMW\Site;
57

@@ -289,7 +291,8 @@ public function getText( $outputformat, $linker = null ) {
289291
$titletext = $this->mTarget;
290292
}
291293

292-
$title = Title::newFromText( $titletext );
294+
$titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
295+
$title = $titleFactory->newFromText( $titletext );
293296

294297
if ( $title !== null ) {
295298
if ( $outputformat == SMW_OUTPUT_WIKI ) {
@@ -304,7 +307,7 @@ public function getText( $outputformat, $linker = null ) {
304307
// a direct URL link (only possible if offending target parts belong
305308
// to some parameter that can be separated from title text, e.g.
306309
// as in Special:Bla/il<leg>al -> Special:Bla&p=il&lt;leg&gt;al)
307-
$title = Title::newFromText( $this->mTarget );
310+
$title = $titleFactory->newFromText( $this->mTarget );
308311

309312
// Just give up due to the title being bad, normally this would
310313
// indicate a software bug
@@ -387,7 +390,7 @@ public function getURL() {
387390
return $this->buildTarget( $query );
388391
}
389392

390-
$title = Title::newFromText( $this->mTarget );
393+
$title = MediaWikiServices::getInstance()->getTitleFactory()->newFromText( $this->mTarget );
391394

392395
if ( $title !== null ) {
393396
return $title->getFullURL( $query );
@@ -413,7 +416,7 @@ public function getLocalURL() {
413416
return $this->buildTarget( $query );
414417
}
415418

416-
$title = Title::newFromText( $this->mTarget );
419+
$title = MediaWikiServices::getInstance()->getTitleFactory()->newFromText( $this->mTarget );
417420

418421
if ( $title !== null ) {
419422
return $title->getLocalURL( $query );

includes/SMW_Outputs.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
use MediaWiki\Output\OutputPage;
4+
use MediaWiki\Parser\Parser;
5+
use MediaWiki\Parser\ParserOutput;
6+
37
/**
48
* This class attempts to provide safe yet simple means for managing data that is relevant
59
* for the final HTML output of MediaWiki. In particular, this concerns additions to the HTML

includes/SMW_PageLister.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use MediaWiki\Title\Title;
34
use SMW\DataValueFactory;
45
use SMW\DIWikiPage;
56
use SMW\Localizer\Localizer;

includes/SMW_PageSchemas.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
* @ingroup SMW
1010
*/
1111

12+
use MediaWiki\Context\RequestContext;
13+
use MediaWiki\Html\Html;
1214
use MediaWiki\MediaWikiServices;
15+
use MediaWiki\Xml\Xml;
1316

1417
class SMWPageSchemas extends PSExtensionHandler {
1518

@@ -115,17 +118,18 @@ public static function getPagesToGenerate( $pageSchemaObj ) {
115118
$pagesToGenerate = [];
116119

117120
$psTemplates = $pageSchemaObj->getTemplates();
121+
$titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
118122
foreach ( $psTemplates as $psTemplate ) {
119123
$smwConnectingPropertyName = self::getConnectingPropertyName( $psTemplate );
120124
if ( $smwConnectingPropertyName === null ) {
121125
continue;
122126
}
123-
$pagesToGenerate[] = Title::makeTitleSafe( SMW_NS_PROPERTY, $smwConnectingPropertyName );
127+
$pagesToGenerate[] = $titleFactory->makeTitleSafe( SMW_NS_PROPERTY, $smwConnectingPropertyName );
124128
}
125129

126130
$propertyDataArray = self::getAllPropertyData( $pageSchemaObj );
127131
foreach ( $propertyDataArray as $propertyData ) {
128-
$title = Title::makeTitleSafe( SMW_NS_PROPERTY, $propertyData['name'] );
132+
$title = $titleFactory->makeTitleSafe( SMW_NS_PROPERTY, $propertyData['name'] );
129133
$pagesToGenerate[] = $title;
130134
}
131135
return $pagesToGenerate;
@@ -260,6 +264,8 @@ public static function getFieldEditingHTML( $psTemplateField ) {
260264
* passed-in Page Schemas XML object.
261265
*/
262266
public static function generatePages( $pageSchemaObj, $selectedPages ) {
267+
$services = MediaWikiServices::getInstance();
268+
$titleFactory = $services->getTitleFactory();
263269
$datatypeLabels = smwfContLang()->getDatatypeLabels();
264270
$pageTypeLabel = $datatypeLabels['_wpg'];
265271

@@ -274,7 +280,7 @@ public static function generatePages( $pageSchemaObj, $selectedPages ) {
274280
if ( $smwConnectingPropertyName === null ) {
275281
continue;
276282
}
277-
$propTitle = Title::makeTitleSafe( SMW_NS_PROPERTY, $smwConnectingPropertyName );
283+
$propTitle = $titleFactory->makeTitleSafe( SMW_NS_PROPERTY, $smwConnectingPropertyName );
278284
if ( !in_array( $propTitle, $selectedPages ) ) {
279285
continue;
280286
}
@@ -286,7 +292,7 @@ public static function generatePages( $pageSchemaObj, $selectedPages ) {
286292
// Second, create jobs for all regular properties.
287293
$propertyDataArray = self::getAllPropertyData( $pageSchemaObj );
288294
foreach ( $propertyDataArray as $propertyData ) {
289-
$propTitle = Title::makeTitleSafe( SMW_NS_PROPERTY, $propertyData['name'] );
295+
$propTitle = $titleFactory->makeTitleSafe( SMW_NS_PROPERTY, $propertyData['name'] );
290296
if ( !in_array( $propTitle, $selectedPages ) ) {
291297
continue;
292298
}
@@ -297,7 +303,7 @@ public static function generatePages( $pageSchemaObj, $selectedPages ) {
297303
$jobs[] = new PSCreatePageJob( $propTitle, $jobParams );
298304
}
299305

300-
MediaWikiServices::getInstance()->getJobQueueGroup()->push( $jobs );
306+
$services->getJobQueueGroup()->push( $jobs );
301307
}
302308

303309
/**

0 commit comments

Comments
 (0)