Skip to content

chore: Update to use /rest/ instead of /bzapi/ for accessing Bugzilla data - #117

Open
dklawren wants to merge 3 commits into
mozilla:mainfrom
dklawren:bzapi-rest
Open

chore: Update to use /rest/ instead of /bzapi/ for accessing Bugzilla data#117
dklawren wants to merge 3 commits into
mozilla:mainfrom
dklawren:bzapi-rest

Conversation

@dklawren

@dklawren dklawren commented Jul 16, 2026

Copy link
Copy Markdown

What changed

  1. Endpoint URL — Bugzilla.php:164
    Switched from the legacy BzAPI proxy to the native REST API: .../bzapi → .../rest.

  2. 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:

  • request_options() — automatically appends *_detail to include_fields on the wire whenever a person field is requested (display columns are left untouched).
  • normalize_person_fields() — folds _detail back onto the bare field after fetch, so templates see the object shape they expect.
  • Rewrote people.tpl to render both a single person object and the cc list of objects (comma-separated, real name with login fallback).
  1. 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.

  2. 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 /bzapi to /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>_detail when 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 thread BugzillaQuery.class.php Outdated
Comment thread templates/fields/people.tpl
Comment thread BugzillaQuery.class.php
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 thread BugzillaQuery.class.php
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);
}
dklawren and others added 2 commits July 16, 2026 17:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants