-
-
Notifications
You must be signed in to change notification settings - Fork 9
fix: Switch to newFromContext to get parser options #46
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
base: master
Are you sure you want to change the base?
fix: Switch to newFromContext to get parser options #46
Conversation
The old way, `RequestContext::getMain()->getOutput()->parserOptions()`, specifically `parserOptions()`, was deprecated in MW 1.44
📝 WalkthroughWalkthroughFormatterBuilder is updated to modify how InlineImageFormatter is instantiated. The ParserOptions initialization method changes from using RequestContext output directly to using ParserOptions::newFromContext(). Additionally, a new string caption parameter is added to the InlineImageFormatter constructor, increasing its arity from four to five. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/Services/FormatterBuilder.php`:
- Around line 29-31: The code calls ParserOptions::newFromContext(...) in the
FormatterBuilder class but does not import ParserOptions, causing PHP to resolve
it to the wrong namespace; add the same use statement for ParserOptions that
InlineImageFormatter uses (or prefix ParserOptions with a leading backslash) so
ParserOptions::newFromContext(RequestContext::getMain()->getOutput()) resolves
correctly; update the imports at the top of the file to include the
ParserOptions class.
| return new InlineImageFormatter( | ||
| RequestContext::getMain()->getOutput()->parserOptions(), | ||
| ParserOptions::newFromContext(RequestContext::getMain()->getOutput()), | ||
| $this->thumbLimits, |
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.
🧩 Analysis chain
🏁 Script executed:
# First, check if there's a local ParserOptions class in the repo
rg -n 'class\s+ParserOptions\b' -SRepository: ProfessionalWiki/WikibaseLocalMedia
Length of output: 61
🏁 Script executed:
# Check the imports in FormatterBuilder.php and look for ParserOptions
cat -n src/Services/FormatterBuilder.php | head -50Repository: ProfessionalWiki/WikibaseLocalMedia
Length of output: 1890
🏁 Script executed:
# Search for where ParserOptions is imported from or defined
rg 'ParserOptions' -B 2 -A 2 | head -100Repository: ProfessionalWiki/WikibaseLocalMedia
Length of output: 1856
Add the missing ParserOptions import (namespace resolution bug).
Line 30 uses ParserOptions::newFromContext(...) without importing it. Without an import or leading backslash, PHP resolves ParserOptions to Wikibase\LocalMedia\Services\ParserOptions, which doesn't exist and will cause a fatal error at runtime. The InlineImageFormatter class correctly imports it; add the same import here.
🛠️ Proposed fix
use RequestContext;
+use ParserOptions;
use ValueFormatters\FormatterOptions;🤖 Prompt for AI Agents
In `@src/Services/FormatterBuilder.php` around lines 29 - 31, The code calls
ParserOptions::newFromContext(...) in the FormatterBuilder class but does not
import ParserOptions, causing PHP to resolve it to the wrong namespace; add the
same use statement for ParserOptions that InlineImageFormatter uses (or prefix
ParserOptions with a leading backslash) so
ParserOptions::newFromContext(RequestContext::getMain()->getOutput()) resolves
correctly; update the imports at the top of the file to include the
ParserOptions class.
|
Cannot drop compatibility with 1.43 yet |
|
Ah, got it |
The old way,
RequestContext::getMain()->getOutput()->parserOptions(), specificallyparserOptions(),was deprecated in MW 1.44
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.