chore: Update to use /rest/ instead of /bzapi/ for accessing Bugzilla data - #117
Open
dklawren wants to merge 3 commits into
Open
chore: Update to use /rest/ instead of /bzapi/ for accessing Bugzilla data#117dklawren wants to merge 3 commits into
dklawren wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the MediaWiki Bugzilla extension to use Bugzilla’s native /rest/ API (instead of legacy /bzapi/) while keeping existing wiki queries and templates working by translating legacy parameters and normalizing REST response shapes.
Changes:
- Switch default API base URL from
/bzapito/rest. - Normalize person-field responses (e.g.,
assigned_to,cc) and update people-field rendering to support lists and singletons uniformly. - Translate legacy BzAPI query parameter names to native REST equivalents, and augment REST requests to include
<field>_detailwhen needed.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
templates/fields/people.tpl |
Renders single-person and multi-person fields uniformly by normalizing inputs to a list and joining rendered entries. |
BugzillaQuery.class.php |
Adds legacy-param translation plus REST person-field detail handling and normalization; adjusts REST request option building. |
Bugzilla.php |
Updates the default REST base URL to /rest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+279
to
+305
| /** | ||
| * Map legacy BzAPI change-history query parameters onto the native REST | ||
| * (buglist.cgi) parameter names. Existing values are never clobbered. | ||
| * | ||
| * @param array $options | ||
| * @return array | ||
| */ | ||
| protected function translate_legacy_params($options) | ||
| { | ||
| $map = array( | ||
| 'changed_after' => 'chfieldfrom', | ||
| 'changed_before' => 'chfieldto', | ||
| 'changed_field' => 'chfield', | ||
| 'changed_field_to' => 'chfieldvalue', | ||
| ); | ||
|
|
||
| foreach ($map as $old => $new) { | ||
| if (array_key_exists($old, $options)) { | ||
| if (!array_key_exists($new, $options)) { | ||
| $options[$new] = $options[$old]; | ||
| } | ||
| unset($options[$old]); | ||
| } | ||
| } | ||
|
|
||
| return $options; | ||
| } |
Comment on lines
+387
to
407
| /** | ||
| * The native REST API returns person fields as a login string (or an array | ||
| * of login strings for 'cc'), with the descriptive object under | ||
| * "<field>_detail". Fold the detail back onto the bare field so the shared | ||
| * people.tpl template receives the object shape it expects. | ||
| */ | ||
| protected function normalize_person_fields() | ||
| { | ||
| if (!isset($this->data['bugs']) || !is_array($this->data['bugs'])) { | ||
| return; | ||
| } | ||
|
|
||
| foreach ($this->data['bugs'] as &$bug) { | ||
| foreach ($this->person_fields as $pf) { | ||
| if (isset($bug[$pf . '_detail'])) { | ||
| $bug[$pf] = $bug[$pf . '_detail']; | ||
| } | ||
| } | ||
| } | ||
| unset($bug); | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Endpoint URL — Bugzilla.php:164
Switched from the legacy BzAPI proxy to the native REST API: .../bzapi → .../rest.
Person fields (assigned_to, creator, qa_contact, cc) — BugzillaQuery.class.php + templates/fields/people.tpl
The native API returns these as login strings (and cc as an array of strings), with the descriptive object under _detail. I:
count type — BugzillaQuery.class.php
The native API has no /count endpoint. It now queries /bug with include_fields=id, so BugzillaNumber (which already counts data['bugs']) keeps working instead of 404ing.
Legacy query-param translation — BugzillaQuery.class.php
translate_legacy_params() maps BzAPI names to native REST names so existing wiki pages keep working:
changed_after→chfieldfrom, changed_before→chfieldto, changed_field→chfield, changed_field_to→chfieldvalue.