Skip to content

Refactor MediaWiki API client to WikiLoginClient#143

Merged
MrIbrahem merged 3 commits intomainfrom
refactor-api-client-wikiloginclient-877470545044727384
May 1, 2026
Merged

Refactor MediaWiki API client to WikiLoginClient#143
MrIbrahem merged 3 commits intomainfrom
refactor-api-client-wikiloginclient-877470545044727384

Conversation

@MrIbrahem
Copy link
Copy Markdown
Collaborator

This PR refactors the MediaWiki API client by replacing the legacy Login class with the more robust WikiLoginClient.

Key changes:

  1. New API Client: Integrated WikiLoginClient which uses mwclient internally and provides better session management, cookie persistence, and automatic retries for CSRF and maxlag.
  2. Pagination Support: Added post_continue to WikiLoginClient to handle MediaWiki API continuation queries, maintaining compatibility with the previous implementation's behavior.
  3. Global Refactoring:
    • Renamed Login to WikiLoginClient throughout the repository.
    • Updated ALL_APIS class to utilize the new client.
    • Replaced all post_params and post calls with client_request.
  4. Bug Fixes:
    • Resolved a "triple-call" bug in the move method where the same API request was mistakenly sent three times.
    • Ensured that the Type parameter in legacy wrappers is correctly mapped to the method parameter in client_request, allowing both GET and POST requests as intended.
  5. Test Updates: Updated the test suite to use the new client and mocked dependencies appropriately.

All tests passed locally.


PR created automatically by Jules for task 877470545044727384 started by @MrIbrahem

- Import WikiLoginClient from cats_maker repository.
- Refactor ALL_APIS to use WikiLoginClient for authentication.
- Implement post_continue method in WikiLoginClient for API pagination.
- Replace all legacy Login class usages with WikiLoginClient.
- Replace post_params and post methods with client_request across the codebase.
- Fix bugs and regressions identified during code review, including duplicate API calls and forced POST requests.
- Update tests to maintain compatibility with the new client.
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@MrIbrahem MrIbrahem marked this pull request as ready for review May 1, 2026 06:36
MrIbrahem added 2 commits May 1, 2026 06:44
- Import the latest WikiLoginClient from the cats_maker repository.
- Implement post_continue method for MediaWiki API pagination.
- Refactor ALL_APIS and all bot/page modules to use WikiLoginClient.
- Replace legacy post_params/post methods with client_request.
- Fix regressions in API wrappers and ensure correct GET/POST method mapping.
- Update test suite to maintain compatibility.
- Integrated the latest WikiLoginClient from cats_maker.
- Re-applied custom improvements:
    - Added post_continue for pagination.
    - Improved session initialization and authentication logic.
    - Handled missing settings by providing defaults for cookies_dir.
- Updated ALL_APIS class and all repository dependencies to use the new client.
- Verified with full test suite.
@MrIbrahem MrIbrahem merged commit d40fbcd into main May 1, 2026
1 check passed
@MrIbrahem MrIbrahem deleted the refactor-api-client-wikiloginclient-877470545044727384 branch May 1, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant