mr widget: exercise greater paranoia about gitlab responses
Attempt to avoid any breakage when GitLab is unavailable or responds in an unexpected way:
- Guard against foreach over anything that is not an array in
getMergeRequestsForTask()
- Wrap
getMergeRequestsForTask()
calls in try-catch - Wrap request via
HTTPSFuture
in try-catch - Check response for a 200 on API request
- Guard against a non-array result for
json_decode()
of response
Also tidies cache logic a bit and removes some debugging boilerplate.
This is a whack-a-mole response rather than a well-reasoned rewrite from scratch, so something could still explode.
Test notes:
- Set
private $task_override = "324164";
to check for a displayed widget for a task with known linked merge requests. - Nothing at all should be displayed if you hit a URL which 404s, or a nonexistent host.
Bug: T333347 Bug: T335504