SemanticMediaWiki
SemanticMediaWiki copied to clipboard
Fix "TypeError: SearchEngineFactory::getSearchEngineClass(): Argument #1 ($dbProvider) must be of type x"
Summary by CodeRabbit
-
New Features
- Enhanced error handling for connection parameters in the search engine classes.
- Increased flexibility in connection type acceptance for search engine instantiation.
-
Bug Fixes
- Improved type validation to prevent runtime errors related to connection types.
[!IMPORTANT]
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
The pull request modifies two search-related classes in the MediaWiki extension to improve type handling and error checking. The changes primarily focus on the constructors and method signatures of ExtendedSearchEngine and SearchEngineFactory, introducing more flexible type handling for database connections. The modifications add runtime type validation to ensure that provided connections meet specific interface requirements, with a forward-looking approach to support future MediaWiki versions.
Changes
| File | Change Summary |
|---|---|
src/MediaWiki/Search/ExtendedSearchEngine.php |
- Constructor parameter changed from IDatabase to generic type- Added runtime type checking for connection parameter - Added comment about future type hint update |
src/MediaWiki/Search/SearchEngineFactory.php |
- newFallbackSearchEngine method parameter changed to union type- Introduced runtime type validation for connection parameter |
Possibly related issues
- #5782 (github/SemanticMediaWiki/SemanticMediaWiki):
- Directly relates to SearchEngineFactory tests failing for MW > 1.40
- Changes in this PR address type compatibility issues with MediaWiki's evolving database connection interfaces
Poem
🐰 Searching far, searching wide, Type checks now dance with pride! Connections flex, no longer tight, Robust code shines ever bright! A rabbit's leap through interface might! 🔍
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Codecov Report
:x: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 55.55%. Comparing base (242a9e2) to head (7ec753d).
:warning: Report is 184 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/MediaWiki/Search/ExtendedSearchEngine.php | 75.00% | 1 Missing :warning: |
| src/MediaWiki/Search/SearchEngineFactory.php | 75.00% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #5886 +/- ##
=========================================
Coverage 55.55% 55.55%
- Complexity 19253 19259 +6
=========================================
Files 982 982
Lines 68818 68826 +8
=========================================
+ Hits 38229 38235 +6
- Misses 30589 30591 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
The code seems good to me, can you coverage with tests as well?
@gesinn-it-gea / @gesinn-it-ilm are you able to look into this please? Specifically $connection = $applicationFactory->getConnectionManager()->getConnection( DB_REPLICA ); which is broken because it returns the wrong type. (Would need to be versioned to use it only on like MW 1.39 and a few others (I forgot which MW release changed the type required).
Unless we can just not use getConnectionManager and instead use MW cores functions?