Skip to content

Conversation

@deer-wmde
Copy link
Contributor

  • refactors Backend\WikiController
  • adds method for new endpoint
  • refactors DB<->MW version mapping into a helper class for reuse

https://phabricator.wikimedia.org/T410394
Bug:T410394

@deer-wmde deer-wmde changed the title De/endpoint wikidb feat: add setWikiDb endpoint Nov 21, 2025
@deer-wmde deer-wmde changed the title feat: add setWikiDb endpoint feat: add endpoint for setting MW DB version Nov 21, 2025
Copy link
Member

@outdooracorn outdooracorn left a comment

Choose a reason for hiding this comment

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

Submitting comments I had so far before going for lunch :)

* this map of mediawikiVersion -> dbVersion lives.
*/

namespace App\Helper;
Copy link
Member

Choose a reason for hiding this comment

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

[non-blocking] I'm now wondering if MediaWikiHostResolver should be a helper as well, rather than a service?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know - I think it was something I suggested back then, but I wouldn't change it again now since we tested the implementation already in all the Jobs etc.

Also as a side note I thought it was quite nice to see this Service pattern getting implemented and how its use can play out with Dependency Injection, so it could be a good example for possible future Service classes

@deer-wmde
Copy link
Contributor Author

trying to summarize what I wondered about API Design here: comparing the patterns used in this PR to @rosalieper I'm unsure which I like more: https://github.com/wbstack/api/pull/1009/files

  • my thinking was trying to fit in this new endpoint in the existing API structure
  • but just looking at Rosalies PR it's much more readable to me what the responsibility of the code is
  • so I'm not sure if it's worth to force this into this Backend WikiController
  • on the other hand then it makes we wonder what the purpose of this Backend WikiController then should be

Overall I think as a team we never fostered much design choices here, so currently we just see lots of different approaches in different parts of the codebase. More compartmentalized code might be the better choice to deal with these circumstances. But we may also miss chances of cleanups we could do along the way.

Any thoughts around this from anyone?

@outdooracorn
Copy link
Member

outdooracorn commented Nov 24, 2025

Thanks for writing your thoughts down, Dena. I think that we should start with a WET implementation of the setWikiDbVersion endpoint. I.e. using a separate controller, duplicating parts of MediaWikiHostResolver if necessary, and not doing any refactoring. This will have the following benefits:

  1. complete the goal of T410394 and unblock T409943
  2. help us understand what the setWikiDbVersion endpoint requires and where the duplicated code is, so that we have as much info as possible to make an informed decision around how best to clean up and refactor the code
  3. keep commits small so that they are easy to review and if any of them introduces a bug, it is easier to identify the buggy commit and revert or fix it

EDIT: Just to be clear, I really want us to improve the code while we are touching it and have the context loaded into our brains. I just think that will be easier to do in separate PRs. :)

@deer-wmde deer-wmde closed this Nov 24, 2025
@tarrow
Copy link
Contributor

tarrow commented Nov 24, 2025

Overall I think as a team we never fostered much design choices here

you are definitely right; in the absence of an obvious pattern to follow I think both are acceptable and I'd not want to block this PR on how it should look.

I think you are right that we should probably try and set some more careful design decisions though.

My personal preference is for smaller single classes with one endpoint and many methods (GET, POST) etc. in that file

deer-wmde added a commit that referenced this pull request Nov 25, 2025
successor of #1010

Adds the backend endpoint `/backend/setWikiDbVersion` as defined in
https://phabricator.wikimedia.org/T410394
deer-wmde added a commit that referenced this pull request Nov 25, 2025
separated from #1010

- adds input validation
- adds unit test
- makes wiki retrieving safer
- removes some special dev handling that is to my knowledge not needed
anymore
- IMO the routing in backend.php here also would need a cleanup, but
that would break client use, so.. meh.
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.

4 participants