-
-
Notifications
You must be signed in to change notification settings - Fork 61
Fix/829 parser not properly initialised #830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/829 parser not properly initialised #830
Conversation
…espacing and initialisation before it can be safely used
📝 WalkthroughWalkthroughThis PR updates import statements across 14 files to use the MediaWiki-namespaced Parser class ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (15)
🧰 Additional context used🧬 Code graph analysis (1)src/SemanticMW/QueryHandler.php (1)
🔇 Additional comments (17)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the codebase to use the namespaced MediaWiki\Parser\Parser class instead of the global \Parser class. The main functional change is in QueryHandler.php, which now properly initializes a Parser instance from ParserFactory and sets it up for external parsing with startExternalParse().
- Updated imports across 14 files to use the namespaced
MediaWiki\Parser\Parserclass - Refactored
QueryHandler::getParser()to create a fresh Parser instance with proper initialization - Added parser instance caching in
QueryHandlerto reuse the same parser for related parsing operations
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/SemanticMW/QueryHandler.php | Refactored parser initialization to use ParserFactory, cache parser instance, and call startExternalParse() |
| src/Presentation/WikitextParser.php | Updated Parser import to use namespaced class |
| src/ParserHooks/MapsDocFunction.php | Updated Parser import to use namespaced class |
| src/ParserHooks/GeocodeFunction.php | Updated Parser import to use namespaced class |
| src/ParserHooks/GeoDistanceFunction.php | Updated Parser import to use namespaced class |
| src/ParserHooks/FindDestinationFunction.php | Updated Parser import to use namespaced class |
| src/ParserHooks/DistanceFunction.php | Updated Parser import to use namespaced class |
| src/ParserHooks/CoordinatesFunction.php | Updated Parser import to use namespaced class |
| src/ParserHookSetup.php | Updated Parser import to use namespaced class |
| src/MapsSetup.php | Updated Parser import to use namespaced class |
| src/MapsFactory.php | Updated Parser import to use namespaced class |
| src/Map/SemanticFormat/MapPrinter.php | Updated Parser import to use namespaced class |
| src/Map/DisplayMap/DisplayMapRenderer.php | Updated Parser import to use namespaced class |
| src/Map/DisplayMap/DisplayMapFunction.php | Updated Parser import to use namespaced class |
| src/Map/CargoFormat/CargoFormat.php | Updated Parser import to use namespaced class |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * * Build a fresh Parser from ParserFactory->create() rather than the global shared instance. | ||
| * * Reuse that initialized Parser for all related parsing that belongs to the same context Title and Options. |
Copilot
AI
Nov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation in comment. Lines 477-478 use spaces instead of tabs for leading whitespace, while line 476 uses a tab.
| * * Build a fresh Parser from ParserFactory->create() rather than the global shared instance. | |
| * * Reuse that initialized Parser for all related parsing that belongs to the same context Title and Options. | |
| * * Build a fresh Parser from ParserFactory->create() rather than the global shared instance. | |
| * * Reuse that initialized Parser for all related parsing that belongs to the same context Title and Options. |
| $this->parser->startExternalParse( | ||
| null, | ||
| $options, | ||
| Parser::OT_HTML, | ||
| true | ||
| ); |
Copilot
AI
Nov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first parameter to startExternalParse() is null, which means the parser has no Title context. This could cause issues with features that depend on page context (like template transclusion, relative links, or page-dependent variables). Consider passing an appropriate Title object if available, or document why null is acceptable in this context.
|
Looks reasonable. Test failures seem the same as on master. Did you manually test this? Some details on version and tests done is useful. |
|
Hello @JeroenDeDauw - yes, it's even on production on Triple Performance with this set of versions (I didn't test on other versions though): Maps version: 13.0.0-alpha (setup with composer: 'mediawiki/maps "^12.0"') |
Fixes #829
Summary by CodeRabbit