Skip to content

Commit be70f40

Browse files
authored
Cast subject page to a Title if it isn't one (#827)
* Cast subject page to a Title if it isn't one This fixes "TypeError: Maps\MapsFactory::newSemanticGeoJsonStore(): Argument #2 ($subjectPage) must be of type MediaWiki\Title\Title, MediaWiki\Page\PageIdentityValue given" Raise MW requirement to 1.41. * Raise MW requirement to 1.43 1.40-1.42 have been EOL for a while. Also remove redundant PHP requirement, since MW 1.43 requires PHP 8. * Only run CI on MW 1.43, 1.44 and master
1 parent bdbbabc commit be70f40

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,12 @@ jobs:
1414
strategy:
1515
matrix:
1616
include:
17-
- mw: 'REL1_40'
18-
php: 7.4
19-
experimental: false
20-
- mw: 'REL1_40'
21-
php: 8.0
22-
experimental: false
23-
- mw: 'REL1_41'
24-
php: 8.1
25-
experimental: false
26-
- mw: 'REL1_42'
27-
php: 8.2
28-
experimental: false
2917
- mw: 'REL1_43'
3018
php: 8.3
3119
experimental: false
20+
- mw: 'REL1_44'
21+
php: 8.3
22+
experimental: false
3223
- mw: 'master'
3324
php: 8.4
3425
experimental: true
@@ -83,13 +74,11 @@ jobs:
8374

8475
- name: Run PHPUnit
8576
run: php tests/phpunit/phpunit.php -c extensions/Maps
86-
if: matrix.mw != 'REL1_43'
8777

8878
- name: Run PHPUnit with code coverage
8979
run: |
9080
php tests/phpunit/phpunit.php -c extensions/Maps --coverage-clover coverage.xml
9181
bash <(curl -s https://codecov.io/bash)
92-
if: matrix.mw == 'REL1_43'
9382
9483
9584
# Psalm:

extension.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
"type": "parserhook",
1313

1414
"requires": {
15-
"MediaWiki": ">= 1.40.0",
16-
"platform": {
17-
"php": ">= 7.4"
18-
}
15+
"MediaWiki": ">= 1.43.0"
1916
},
2017

2118
"AutoloadNamespaces": {

src/GeoJsonPages/GeoJsonContentHandler.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Maps\MapsFactory;
99
use Maps\Presentation\OutputFacade;
1010
use MediaWiki\Content\Renderer\ContentParseParams;
11+
use MediaWiki\Title\Title;
1112
use ParserOutput;
1213

1314
class GeoJsonContentHandler extends \JsonContentHandler {
@@ -47,8 +48,13 @@ protected function fillParserOutput(
4748
// to avoid decoding it again in SubObjectBuilder -> getSubObjectsFromGeoJson
4849
$text = json_encode( $content->getData()->getValue() );
4950

51+
$subjectPage = $cpoParams->getPage();
52+
if ( !$subjectPage instanceof Title ) {
53+
// all underlying methods expect a Title, so cast it to one
54+
$subjectPage = Title::newFromPageReference( $subjectPage );
55+
}
5056
MapsFactory::globalInstance()
51-
->newSemanticGeoJsonStore( $parserOutput, $cpoParams->getPage() )
57+
->newSemanticGeoJsonStore( $parserOutput, $subjectPage )
5258
->storeGeoJson( $text );
5359
}
5460

0 commit comments

Comments
 (0)