-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: propagate status code from platform api when routing wiki requests #410
Conversation
The entire |
fcfcf70
to
6d0272e
Compare
6d0272e
to
b7666ab
Compare
class GlobalSet { | ||
|
||
/** | ||
* @param string $requestDomain A request domain, or 'maint' Example: 'addshore-alpha.wiki.opencura.com' | ||
* @return bool was the global successfully set? | ||
* @return void |
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.
I think this makes sense and probably propagating the precise nature of the failure with an Exception.
In any case this probably makes sense and is then super clear that this is really a side effect only function.
Naturally trying to write this in a clean way is pretty hard since the desired behaviour is charging around a setting a load of globals
*/ | ||
public static function forDomain( $requestDomain ) { | ||
public static function forDomain($requestDomain) { |
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.
So the linting here looks "funny" because MediaWiki uses a very non-php standard code style. No objection to this being changed here since we don't lint this anyway but perhaps in future we should add linting to match the MediaWiki style to this weird codebase in dist-persist
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.
I mean if we want a code style, then it should be applied everywhere. I just tried to make it consistent per function. Which is probably futile ...
If you want to add more "formal" testing you can add stuff to https://github.com/wbstack/mediawiki/blob/main/.github/workflows/mediawiki.verify.yml and to the fake api at https://github.com/wbstack/mediawiki/tree/main/docker-compose/fake-api |
Ah I didn't know about these, that's very helpful. |
26c9b6c
to
0b9240f
Compare
87d1fe5
to
9e14373
Compare
a49fa65
to
0116f75
Compare
@tarrow I refactored this so that it now caches any kind of response and also added "tests". Mind taking another look? |
} | ||
return $info; | ||
|
||
return WBStackInfo::newFromJsonString($response, $requestDomain); |
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.
I think we still need to check what happens here; in the event this parsing fails and the static here returns a null
we should build a WBStackLookupFailure; not quite sure how graceful or not failure would be in this case (since the logic in WBStackInfo is also very unpolished)
I tried this locally in a not super smart way as you can see at #411
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.
Yeah, good catch, we shall add this still. Will do so right away.
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.
b8928e9
to
c6e9bbd
Compare
c6e9bbd
to
75c7bd9
Compare
@@ -0,0 +1 @@ | |||
{"success":tr |
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.
Most realistic!
Ticket: https://phabricator.wikimedia.org/T343744
I tested this locally by: