Skip to content
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

Update for MediaWiki 1.42 and use virtual domain #99

Merged
merged 7 commits into from
Jul 17, 2024
Merged

Conversation

Universal-Omega
Copy link
Member

@Universal-Omega Universal-Omega commented May 14, 2024

Also adds new tests for SpecialRequestImport and ImportDumpRequestManager to ensure new DatabaseVirtualDomains handling. It also adds a new ConfigNames class to improve code standards and protect against typos.

This should not be merged until we want to drop MediaWiki 1.41 support.

Summary by CodeRabbit

  • New Features

    • Updated MediaWiki version requirement to 1.42.0 for better compatibility and performance.
    • Enhanced database connection handling for improved stability.
  • Bug Fixes

    • Fixed import statements and dependencies to align with MediaWiki's updated structure.
  • Refactor

    • Replaced DBLoadBalancerFactory with ConnectionProvider in various classes for more efficient database management.
    • Added ConfigNames to facilitate getting configuration options and to protect against typos.
  • Tests

    • Added comprehensive test cases for SpecialRequestImport to ensure robust functionality and reliability.

@Universal-Omega
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented May 17, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

coderabbitai bot commented May 17, 2024

Walkthrough

The recent updates involve upgrading MediaWiki from version 1.41 to 1.42, along with refactoring dependencies across various files. Notable changes include transitioning from DBLoadBalancerFactory to ConnectionProvider, updating import statements, and enhancing database connection management. Additionally, new test scenarios have been introduced to validate the functionality of the SpecialRequestImport class.

Changes

Files Change Summary
.github/workflows/mediawiki-tests.yml, extension.json Updated MediaWiki version to 1.42 and adjusted service dependencies.
includes/Hooks/Handlers/Installer.php, includes/Hooks/Handlers/Main.php Updated import statements and refactored dependencies to utilize IConnectionProvider.
includes/ImportDumpOOUIForm.php, includes/ImportDumpRequestManager.php, includes/ImportDumpRequestQueuePager.php, includes/ImportDumpRequestViewer.php Revised import statements and improved database connection management.
includes/Jobs/ImportDumpJob.php, includes/Jobs/ImportDumpNotifyJob.php Added and removed imports for RequestContext and SiteStatsUpdate.
includes/Notifications/EchoImportFailedPresentationModel.php, includes/Notifications/EchoNewRequestPresentationModel.php, includes/Notifications/EchoRequestCommentPresentationModel.php, includes/Notifications/EchoRequestStatusUpdatePresentationModel.php Updated import statements for Message.
includes/ServiceWiring.php Introduced import for RequestContext and adjusted service instantiation.
includes/Specials/SpecialRequestImport.php, includes/Specials/SpecialRequestImportQueue.php Updated import statements and refactored database handling logic.
includes/ImportDumpRequestManagerTest.php, tests/phpunit/SpecialRequestImportTest.php Added new test cases and updated existing ones to reflect changes in dependencies and functionality.

🐇
In the world of code, we hop and play,
Updating versions, come what may.
With ConnectionProvider in our pack,
We never fear, we stay on track.
MediaWiki's new dawn, 1.42,
Brings fresh fields, bright and true.
Let's celebrate with a joyful cheer,
For our code is now crystal clear!
🐇


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?

Share
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>.
    • 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 @coderabbitai in 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 @coderabbitai in 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3f32b1f and 20fae9f.
Files selected for processing (18)
  • .github/workflows/mediawiki-tests.yml (1 hunks)
  • extension.json (6 hunks)
  • includes/Hooks/Handlers/Installer.php (1 hunks)
  • includes/Hooks/Handlers/Main.php (4 hunks)
  • includes/ImportDumpOOUIForm.php (1 hunks)
  • includes/ImportDumpRequestManager.php (5 hunks)
  • includes/ImportDumpRequestQueuePager.php (4 hunks)
  • includes/ImportDumpRequestViewer.php (4 hunks)
  • includes/Jobs/ImportDumpJob.php (4 hunks)
  • includes/Jobs/ImportDumpNotifyJob.php (1 hunks)
  • includes/Notifications/EchoImportFailedPresentationModel.php (1 hunks)
  • includes/Notifications/EchoNewRequestPresentationModel.php (1 hunks)
  • includes/Notifications/EchoRequestCommentPresentationModel.php (1 hunks)
  • includes/Notifications/EchoRequestStatusUpdatePresentationModel.php (1 hunks)
  • includes/ServiceWiring.php (2 hunks)
  • includes/Specials/SpecialRequestImport.php (4 hunks)
  • includes/Specials/SpecialRequestImportQueue.php (2 hunks)
  • tests/phpunit/ImportDumpRequestManagerTest.php (2 hunks)
Files skipped from review due to trivial changes (9)
  • .github/workflows/mediawiki-tests.yml
  • includes/Hooks/Handlers/Installer.php
  • includes/ImportDumpOOUIForm.php
  • includes/Jobs/ImportDumpNotifyJob.php
  • includes/Notifications/EchoImportFailedPresentationModel.php
  • includes/Notifications/EchoNewRequestPresentationModel.php
  • includes/Notifications/EchoRequestCommentPresentationModel.php
  • includes/Notifications/EchoRequestStatusUpdatePresentationModel.php
  • includes/Specials/SpecialRequestImportQueue.php
Additional comments not posted (19)
includes/ServiceWiring.php (1)

14-14: Change from DBLoadBalancerFactory to ConnectionProvider aligns with the PR's objectives for dependency updates.

Verification successful

The search results indicate that ConnectionProvider is being used across the codebase, replacing DBLoadBalancerFactory. Here are the files where ConnectionProvider is used:

  • tests/phpunit/ImportDumpRequestManagerTest.php
  • includes/ServiceWiring.php
  • includes/ImportDumpRequestManager.php
  • includes/ImportDumpRequestQueuePager.php
  • includes/Specials/SpecialRequestImportQueue.php
  • includes/Specials/SpecialRequestImport.php
  • includes/Jobs/ImportDumpJob.php
  • includes/Hooks/Handlers/Main.php

This confirms that the dependency update has been applied consistently.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `ConnectionProvider` is properly used in place of `DBLoadBalancerFactory` across the codebase.

# Test: Search for the old dependency usage. Expect: No occurrences of `DBLoadBalancerFactory`.
rg --type php 'DBLoadBalancerFactory'

Length of output: 37



Script:

#!/bin/bash
# Description: Verify that `ConnectionProvider` is properly used across the codebase.

# Test: Search for the new dependency usage. Expect: Occurrences of `ConnectionProvider`.
rg --type php 'ConnectionProvider'

Length of output: 2131

tests/phpunit/ImportDumpRequestManagerTest.php (1)

17-37: Implementation of ImportDumpStatus and updates to test setup are appropriate and align with the main codebase changes.

includes/ImportDumpRequestQueuePager.php (1)

50-50: Updated database connection handling using ConnectionProvider is correctly implemented.

includes/Hooks/Handlers/Main.php (1)

Line range hint 29-48: Constructor and method updates to use ConnectionProvider are correctly implemented, ensuring compatibility with the new MediaWiki version.

extension.json (1)

10-10: Updates to the MediaWiki version requirement and service configurations in extension.json are correctly implemented.

Also applies to: 32-114, 158-158

Verification successful

The onLoginFormValidErrorMessages method in the Main class correctly implements the LoginFormValidErrorMessagesHook interface. No compatibility issues were found with the new MediaWiki version.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the extension functions correctly with the new MediaWiki version and dependencies.

# Test: Check for any compatibility issues reported in logs.
rg --type json 'MediaWiki' | grep 'Error'

Length of output: 39



Script:

#!/bin/bash
# Description: Verify that the extension functions correctly with the new MediaWiki version and dependencies.

# Test: Check for any compatibility issues reported in logs or other relevant files.
rg 'MediaWiki' | grep -i 'error\|warning'

Length of output: 126



Script:

#!/bin/bash
# Description: Extract the relevant lines around the `LoginFormValidErrorMessagesHook` usage in `includes/Hooks/Handlers/Main.php`.

# Extract lines around the reference to `LoginFormValidErrorMessagesHook`.
rg --context 5 'LoginFormValidErrorMessagesHook' includes/Hooks/Handlers/Main.php

Length of output: 931



Script:

#!/bin/bash
# Description: Extract the implementation of the `LoginFormValidErrorMessagesHook` interface in the `Main` class.

# Extract the implementation of the `LoginFormValidErrorMessagesHook` interface.
ast-grep --lang php --pattern 'class Main implements LoginFormValidErrorMessagesHook { $$$ }' includes/Hooks/Handlers/Main.php

Length of output: 235



Script:

#!/bin/bash
# Description: Extract the implementation of the `LoginFormValidErrorMessagesHook` interface in the `Main` class.

# Extract method implementations in the `Main` class.
rg --pcre2 --context 10 'class Main.*\{|\bfunction\b' includes/Hooks/Handlers/Main.php

Length of output: 1657

includes/Jobs/ImportDumpJob.php (1)

Line range hint 12-133: Constructor and import method updates in ImportDumpJob are correctly implemented, ensuring compatibility with the new MediaWiki version.

includes/Specials/SpecialRequestImport.php (1)

Line range hint 12-197: Constructor and method updates in SpecialRequestImport are correctly implemented, ensuring compatibility with the new MediaWiki version.

Also applies to: 390-406

includes/ImportDumpRequestManager.php (4)

15-15: Added import for MediaWiki\Message\Message.

This change aligns with the PR's objective to update namespace usage across the project for better maintainability and compatibility with MediaWiki 1.42.


138-138: Updated database connection logic to use IConnectionProvider.

This change is part of the dependency refactoring to replace DBLoadBalancerFactory with ConnectionProvider. It ensures that the class uses the updated dependency correctly.


310-310: Refactored insertInterwikiPrefix to use the new database connection method.

This update is consistent with the overall PR's goal of dependency refactoring. It correctly utilizes the new IConnectionProvider interface for database operations, enhancing maintainability.


360-360: Enhanced getInterwikiPrefix to use the new database connection method.

This modification is part of the dependency refactoring, ensuring that the method uses the updated IConnectionProvider interface. It's a good practice to keep the database interaction methods consistent across the class.

includes/ImportDumpRequestViewer.php (8)

6-6: Namespace adjustment for IContextSource is correct and aligns with the PR objectives.


8-8: Namespace adjustment for HTMLForm is correct and aligns with the PR objectives.


11-11: Namespace adjustment for Message is correct and aligns with the PR objectives.


449-453: The validation method isValidComment correctly checks for empty or whitespace-only comments. This is a good practice to ensure meaningful user input.


461-465: The validation method isValidDatabase correctly checks if the provided database target is in the list of local databases. This is crucial for ensuring that operations are performed on valid databases.


473-477: The validation method isValidReason correctly checks for empty or whitespace-only reasons. This is important for ensuring that reasons provided are meaningful and not just blank inputs.


486-490: The validation method isValidInterwikiPrefix correctly checks for empty or whitespace-only interwiki prefixes. This ensures that the prefixes used are valid and meaningful.


499-514: The validation method isValidInterwikiUrl correctly checks for empty or whitespace-only URLs and validates the URL structure. This is crucial for ensuring that the URLs used are valid and properly formatted.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 20fae9f and 64850ff.
Files selected for processing (2)
  • includes/ImportDumpRequestViewer.php (4 hunks)
  • includes/Specials/SpecialRequestImport.php (4 hunks)
Files skipped from review as they are similar to previous changes (2)
  • includes/ImportDumpRequestViewer.php
  • includes/Specials/SpecialRequestImport.php

P.S. I deleted comments below to clean up this PR, but they were related to creating SpecialRequestImportTest --@Universal-Omega

@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@miraheze miraheze deleted a comment from coderabbitai bot May 19, 2024
@Universal-Omega
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented May 19, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 64850ff and 52ea566.
Files selected for processing (4)
  • includes/Hooks/Handlers/Main.php (4 hunks)
  • includes/Jobs/ImportDumpJob.php (4 hunks)
  • includes/Specials/SpecialRequestImport.php (4 hunks)
  • tests/phpunit/SpecialRequestImportTest.php (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • includes/Hooks/Handlers/Main.php
  • includes/Jobs/ImportDumpJob.php
  • includes/Specials/SpecialRequestImport.php
Additional Context Used
Path-based Instructions (1)
tests/phpunit/SpecialRequestImportTest.php (1)

Pattern **/*.php: Follow MediaWiki PHP Coding Standards:

Indentation:

  • Use tabs for indentation, not spaces.

Spaces:

  • Use spaces on either side of binary operators.
    Example: $a = $b + $c; (Correct) $a=$b+$c; (Incorrect)
  • Add spaces inside parentheses, except where they are empty.
    Example: $a = getFoo( $b ); (Correct) $a = getFoo($b); (Incorrect)
  • Do not add a space after a function name.
    Example: $c = getBar(); (Correct) $c = getBar (); (Incorrect)

Function Return Type Hint:

  • Add a space after the colon in the function return type hint.
    Example: function square( int $x ): int { return $x * $x; }

Arrays:

  • Use spaces in brackets when declaring an array, except where the array is empty.
    Example: $a = [ 'foo', 'bar' ]; (Correct) $a = ['foo', 'bar']; (Incorrect)
  • Do not put spaces in brackets when accessing array elements.
    Example: $c = $a[0]; (Correct) $c = $a[ 0 ]; (Incorrect)

Control Structures:

  • Add a space after control structure keywords.
    Example: if ( isFoo() ) { ... } (Correct) if(isFoo()){ ... } (Incorrect)

Type Casting:

  • Do not use a space within or after the cast operator.
    Example: (int)$foo; (Correct) (int) $bar; (Incorrect)

Comments:

  • In comments, there should be one space between the # or // and the comment text.
    Example: // This is a comment. (Correct) //This is a comment. (Incorrect)

Ternary Operator:

  • Keep ternary operator expressions short and obvious.
  • For multi-line ternary expressions, place the '?' and ':' at the beginning of the new lines.

File Formatting:
- Avoid trailing whitespace on lines.

Learnings (1)
tests/phpunit/SpecialRequestImportTest.php (2)
User: Universal-Omega
PR: miraheze/ImportDump#99
File: includes/Specials/SpecialRequestImport.php:9-9
Timestamp: 2024-05-18T23:25:00.346Z
Learning: When generating unit tests for MediaWiki special pages, use data providers for validation callbacks, add @covers and @group comments, and ensure to mock dependencies like IConnectionProvider, MimeAnalyzer, PermissionManager, RepoGroup, and UserFactory.
User: Universal-Omega
PR: miraheze/ImportDump#99
File: includes/Specials/SpecialRequestImport.php:9-9
Timestamp: 2024-05-18T23:09:23.415Z
Learning: When generating unit tests for MediaWiki special pages, ensure to mock dependencies like IConnectionProvider, MimeAnalyzer, PermissionManager, RepoGroup, and UserFactory.
Additional comments not posted (12)
tests/phpunit/SpecialRequestImportTest.php (12)

29-44: Setup method correctly initializes dependencies for SpecialRequestImport.


46-51: Cleanup process in tearDown method is implemented correctly.


57-59: Constructor test correctly verifies object instantiation.


64-75: Execution test method is thorough and correctly tests the behavior of SpecialRequestImport.


80-84: Logged out test correctly expects an exception, ensuring proper access control.


90-129: Submission test method is well-structured and effectively uses a data provider to test various scenarios.


136-158: Data provider for onSubmit test method correctly supplies both valid and invalid scenarios.


164-211: Duplicate submission test method correctly ensures that duplicates are detected and handled appropriately.


217-223: Database validation test method correctly uses a data provider to test various scenarios.


231-235: Data provider for isValidDatabase test method correctly supplies both valid and invalid scenarios.


242-248: Reason validation test method correctly uses a data provider to test various scenarios.


256-260: Data provider for isValidReason test method correctly supplies both valid and invalid scenarios.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 52ea566 and e147b3d.
Files selected for processing (1)
  • tests/phpunit/SpecialRequestImportTest.php (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/phpunit/SpecialRequestImportTest.php

@redbluegreenhat redbluegreenhat removed their request for review May 21, 2024 17:07
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e147b3d and 3e518dd.
Files selected for processing (2)
  • tests/phpunit/ImportDumpRequestManagerTest.php (4 hunks)
  • tests/phpunit/SpecialRequestImportTest.php (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/phpunit/ImportDumpRequestManagerTest.php
Additional Context Used
Path-based Instructions (1)
tests/phpunit/SpecialRequestImportTest.php (1)

Pattern **/*.php: Follow MediaWiki PHP Coding Standards:

Indentation:

  • Use tabs for indentation, not spaces.

Spaces:

  • Use spaces on either side of binary operators.
    Example: $a = $b + $c; (Correct) $a=$b+$c; (Incorrect)
  • Add spaces inside parentheses, except where they are empty.
    Example: $a = getFoo( $b ); (Correct) $a = getFoo($b); (Incorrect)
  • Do not add a space after a function name.
    Example: $c = getBar(); (Correct) $c = getBar (); (Incorrect)

Function Return Type Hint:

  • Add a space after the colon in the function return type hint.
    Example: function square( int $x ): int { return $x * $x; }

Arrays:

  • Use spaces in brackets when declaring an array, except where the array is empty.
    Example: $a = [ 'foo', 'bar' ]; (Correct) $a = ['foo', 'bar']; (Incorrect)
  • Do not put spaces in brackets when accessing array elements.
    Example: $c = $a[0]; (Correct) $c = $a[ 0 ]; (Incorrect)

Control Structures:

  • Add a space after control structure keywords.
    Example: if ( isFoo() ) { ... } (Correct) if(isFoo()){ ... } (Incorrect)

Type Casting:

  • Do not use a space within or after the cast operator.
    Example: (int)$foo; (Correct) (int) $bar; (Incorrect)

Comments:

  • In comments, there should be one space between the # or // and the comment text.
    Example: // This is a comment. (Correct) //This is a comment. (Incorrect)

Ternary Operator:

  • Keep ternary operator expressions short and obvious.
  • For multi-line ternary expressions, place the '?' and ':' at the beginning of the new lines.

File Formatting:
- Avoid trailing whitespace on lines.

Learnings (1)
tests/phpunit/SpecialRequestImportTest.php (2)
User: Universal-Omega
PR: miraheze/ImportDump#99
File: includes/Specials/SpecialRequestImport.php:9-9
Timestamp: 2024-05-18T23:25:00.346Z
Learning: When generating unit tests for MediaWiki special pages, use data providers for validation callbacks, add @covers and @group comments, and ensure to mock dependencies like IConnectionProvider, MimeAnalyzer, PermissionManager, RepoGroup, and UserFactory.
User: Universal-Omega
PR: miraheze/ImportDump#99
File: includes/Specials/SpecialRequestImport.php:9-9
Timestamp: 2024-05-18T23:09:23.415Z
Learning: When generating unit tests for MediaWiki special pages, ensure to mock dependencies like IConnectionProvider, MimeAnalyzer, PermissionManager, RepoGroup, and UserFactory.
Additional comments not posted (12)
tests/phpunit/SpecialRequestImportTest.php (12)

35-44: Constructor setup correctly initializes SpecialRequestImport with necessary dependencies.


47-54: setUp method correctly configures global settings and initializes the test object.


57-60: tearDown method correctly handles cleanup of test resources.


68-69: testConstructor correctly verifies the object type of specialRequestImport.


75-78: testExecute method correctly simulates the special page execution and verifies the output.


84-86: testExecuteNotLoggedIn correctly handles the scenario where a user is not logged in.


93-140: testOnSubmit method and its data provider correctly test the form submission logic with various scenarios.


235-241: testIsValidDatabase method and its data provider correctly test the database validation logic.


258-263: testIsValidReason method and its data provider correctly test the reason validation logic.


280-316: testGetFormFields method correctly tests the form fields generated by the special page under various configurations.


322-331: testCheckPermissions method correctly tests the permission checking logic of the special page.


337-339: testGetLogType method correctly retrieves the log type associated with the special page.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 3e518dd and 36ce792.
Files selected for processing (19)
  • .github/workflows/mediawiki-tests.yml (1 hunks)
  • extension.json (6 hunks)
  • includes/Hooks/Handlers/Installer.php (1 hunks)
  • includes/Hooks/Handlers/Main.php (4 hunks)
  • includes/ImportDumpOOUIForm.php (1 hunks)
  • includes/ImportDumpRequestManager.php (5 hunks)
  • includes/ImportDumpRequestQueuePager.php (4 hunks)
  • includes/ImportDumpRequestViewer.php (4 hunks)
  • includes/Jobs/ImportDumpJob.php (4 hunks)
  • includes/Jobs/ImportDumpNotifyJob.php (1 hunks)
  • includes/Notifications/EchoImportFailedPresentationModel.php (1 hunks)
  • includes/Notifications/EchoNewRequestPresentationModel.php (1 hunks)
  • includes/Notifications/EchoRequestCommentPresentationModel.php (1 hunks)
  • includes/Notifications/EchoRequestStatusUpdatePresentationModel.php (1 hunks)
  • includes/ServiceWiring.php (2 hunks)
  • includes/Specials/SpecialRequestImport.php (4 hunks)
  • includes/Specials/SpecialRequestImportQueue.php (2 hunks)
  • tests/phpunit/ImportDumpRequestManagerTest.php (4 hunks)
  • tests/phpunit/SpecialRequestImportTest.php (1 hunks)
Files skipped from review as they are similar to previous changes (19)
  • .github/workflows/mediawiki-tests.yml
  • extension.json
  • includes/Hooks/Handlers/Installer.php
  • includes/Hooks/Handlers/Main.php
  • includes/ImportDumpOOUIForm.php
  • includes/ImportDumpRequestManager.php
  • includes/ImportDumpRequestQueuePager.php
  • includes/ImportDumpRequestViewer.php
  • includes/Jobs/ImportDumpJob.php
  • includes/Jobs/ImportDumpNotifyJob.php
  • includes/Notifications/EchoImportFailedPresentationModel.php
  • includes/Notifications/EchoNewRequestPresentationModel.php
  • includes/Notifications/EchoRequestCommentPresentationModel.php
  • includes/Notifications/EchoRequestStatusUpdatePresentationModel.php
  • includes/ServiceWiring.php
  • includes/Specials/SpecialRequestImport.php
  • includes/Specials/SpecialRequestImportQueue.php
  • tests/phpunit/ImportDumpRequestManagerTest.php
  • tests/phpunit/SpecialRequestImportTest.php

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 36ce792 and e1a5c0a.
Files selected for processing (1)
  • tests/phpunit/Specials/SpecialRequestImportTest.php (1 hunks)
Additional Context Used
Path-based Instructions (1)
tests/phpunit/Specials/SpecialRequestImportTest.php (1)

Pattern **/*.php: Follow MediaWiki PHP Coding Standards:

Indentation:

  • Use tabs for indentation, not spaces.

Spaces:

  • Use spaces on either side of binary operators.
    Example: $a = $b + $c; (Correct) $a=$b+$c; (Incorrect)
  • Add spaces inside parentheses, except where they are empty.
    Example: $a = getFoo( $b ); (Correct) $a = getFoo($b); (Incorrect)
  • Do not add a space after a function name.
    Example: $c = getBar(); (Correct) $c = getBar (); (Incorrect)

Function Return Type Hint:

  • Add a space after the colon in the function return type hint.
    Example: function square( int $x ): int { return $x * $x; }

Arrays:

  • Use spaces in brackets when declaring an array, except where the array is empty.
    Example: $a = [ 'foo', 'bar' ]; (Correct) $a = ['foo', 'bar']; (Incorrect)
  • Do not put spaces in brackets when accessing array elements.
    Example: $c = $a[0]; (Correct) $c = $a[ 0 ]; (Incorrect)

Control Structures:

  • Add a space after control structure keywords.
    Example: if ( isFoo() ) { ... } (Correct) if(isFoo()){ ... } (Incorrect)

Type Casting:

  • Do not use a space within or after the cast operator.
    Example: (int)$foo; (Correct) (int) $bar; (Incorrect)

Comments:

  • In comments, there should be one space between the # or // and the comment text.
    Example: // This is a comment. (Correct) //This is a comment. (Incorrect)

Ternary Operator:

  • Keep ternary operator expressions short and obvious.
  • For multi-line ternary expressions, place the '?' and ':' at the beginning of the new lines.

File Formatting:
- Avoid trailing whitespace on lines.

Learnings (1)
tests/phpunit/Specials/SpecialRequestImportTest.php (2)
User: Universal-Omega
PR: miraheze/ImportDump#99
File: includes/Specials/SpecialRequestImport.php:9-9
Timestamp: 2024-05-18T23:25:00.346Z
Learning: When generating unit tests for MediaWiki special pages, use data providers for validation callbacks, add @covers and @group comments, and ensure to mock dependencies like IConnectionProvider, MimeAnalyzer, PermissionManager, RepoGroup, and UserFactory.
User: Universal-Omega
PR: miraheze/ImportDump#99
File: includes/Specials/SpecialRequestImport.php:9-9
Timestamp: 2024-05-18T23:09:23.415Z
Learning: When generating unit tests for MediaWiki special pages, ensure to mock dependencies like IConnectionProvider, MimeAnalyzer, PermissionManager, RepoGroup, and UserFactory.
Additional comments not posted (14)
tests/phpunit/Specials/SpecialRequestImportTest.php (14)

28-28: Ensure the class declaration follows MediaWiki PHP coding standards.


35-45: The newSpecialPage method correctly implements dependency injection for creating the SpecialRequestImport instance.


47-55: The setUp method appropriately configures the testing environment and initializes the SpecialRequestImport instance.


57-63: The tearDown method correctly handles cleanup by removing the test file if it exists, ensuring no side effects between tests.


68-70: The testConstructor method correctly asserts that the specialRequestImport instance is of the expected class.


75-79: The testExecute method correctly simulates the page execution and checks the output, effectively testing the execute method of SpecialRequestImport.


84-87: The testExecuteNotLoggedIn method correctly expects a UserNotLoggedIn exception, appropriately testing access control in the execute method.


93-141: The testOnSubmit method effectively tests the onSubmit method of SpecialRequestImport using various data scenarios provided by onSubmitDataProvider. The method setups and assertions are correctly implemented for each scenario.

Also applies to: 148-229


235-241: The testIsValidDatabase method correctly tests the isValidDatabase method of SpecialRequestImport using scenarios provided by isValidDatabaseDataProvider. The assertions are appropriately implemented for each scenario.

Also applies to: 249-252


258-264: The testIsValidReason method correctly tests the isValidReason method of SpecialRequestImport using scenarios provided by isValidReasonDataProvider. The assertions are appropriately implemented for each scenario.

Also applies to: 272-275


280-317: The testGetFormFields method correctly tests the form fields returned by getFormFields, ensuring that fields are correctly included or excluded based on configuration settings.


322-332: The testCheckPermissions method correctly tests the checkPermissions method of SpecialRequestImport, ensuring that it behaves as expected under normal conditions.


337-339: The testGetLogType method correctly asserts that the log type returned is as expected, ensuring that logging is categorized correctly.


348-353: The setSessionUser method correctly manipulates the RequestContext and session to set the user, facilitating tests that require user sessions.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e1a5c0a and 8bbec0b.
Files selected for processing (1)
  • extension.json (6 hunks)
Files skipped from review as they are similar to previous changes (1)
  • extension.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 8bbec0b and 84fa660.
Files selected for processing (5)
  • includes/ConfigNames.php (1 hunks)
  • includes/ImportDumpRequestManager.php (7 hunks)
  • includes/ImportDumpRequestViewer.php (8 hunks)
  • includes/Jobs/ImportDumpNotifyJob.php (2 hunks)
  • includes/Specials/SpecialRequestImport.php (6 hunks)
Files skipped from review due to trivial changes (1)
  • includes/ConfigNames.php
Files skipped from review as they are similar to previous changes (3)
  • includes/ImportDumpRequestManager.php
  • includes/ImportDumpRequestViewer.php
  • includes/Jobs/ImportDumpNotifyJob.php
Additional Context Used
Path-based Instructions (1)
includes/Specials/SpecialRequestImport.php (1)

Pattern **/*.php: Follow MediaWiki PHP Coding Standards:

Indentation:

  • Use tabs for indentation, not spaces.

Spaces:

  • Use spaces on either side of binary operators.
    Example: $a = $b + $c; (Correct) $a=$b+$c; (Incorrect)
  • Add spaces inside parentheses, except where they are empty.
    Example: $a = getFoo( $b ); (Correct) $a = getFoo($b); (Incorrect)
  • Do not add a space after a function name.
    Example: $c = getBar(); (Correct) $c = getBar (); (Incorrect)

Function Return Type Hint:

  • Add a space after the colon in the function return type hint.
    Example: function square( int $x ): int { return $x * $x; }

Arrays:

  • Use spaces in brackets when declaring an array, except where the array is empty.
    Example: $a = [ 'foo', 'bar' ]; (Correct) $a = ['foo', 'bar']; (Incorrect)
  • Do not put spaces in brackets when accessing array elements.
    Example: $c = $a[0]; (Correct) $c = $a[ 0 ]; (Incorrect)

Control Structures:

  • Add a space after control structure keywords.
    Example: if ( isFoo() ) { ... } (Correct) if(isFoo()){ ... } (Incorrect)

Type Casting:

  • Do not use a space within or after the cast operator.
    Example: (int)$foo; (Correct) (int) $bar; (Incorrect)

Comments:

  • In comments, there should be one space between the # or // and the comment text.
    Example: // This is a comment. (Correct) //This is a comment. (Incorrect)

Ternary Operator:

  • Keep ternary operator expressions short and obvious.
  • For multi-line ternary expressions, place the '?' and ':' at the beginning of the new lines.

File Formatting:
- Avoid trailing whitespace on lines.

Additional comments not posted (3)
includes/Specials/SpecialRequestImport.php (3)

12-12: The new imports and the implementation of ImportDumpStatus are correctly aligned with the PR's objectives to handle virtual domains and update dependencies.

Also applies to: 23-23


88-89: The modifications in the execute method to use getReplicaDatabase with a domain and to check the current wiki's domain are well-implemented and necessary for the support of virtual domains.

Also applies to: 95-96


198-198: The changes in the onSubmit method, including the use of getPrimaryDatabase with a domain, handling of file uploads, and checks for duplicates and valid inputs, are well-implemented and enhance the functionality and security of the import process.

Also applies to: 321-321, 357-357, 391-395, 403-407

@redbluegreenhat redbluegreenhat marked this pull request as ready for review July 13, 2024 16:20
@redbluegreenhat redbluegreenhat merged commit fd9ab0e into master Jul 17, 2024
3 checks passed
@redbluegreenhat redbluegreenhat deleted the REL1_42 branch July 17, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants