Skip to content

Commit 35ed08b

Browse files
committed
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.
1 parent f3df101 commit 35ed08b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

extension.json

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

1414
"requires": {
15-
"MediaWiki": ">= 1.40.0",
15+
"MediaWiki": ">= 1.41.0",
1616
"platform": {
1717
"php": ">= 7.4"
1818
}

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)