Skip to content

Bug 2091444 - TrackingFlags bug_check_can_change_field runs a database query for every custom field on show_bug.cgi, including fields that aren't tracking flags - #2824

Merged
dklawren merged 5 commits into
mozilla:masterfrom
dklawren:2091444
Nov 12, 2026

Conversation

@dklawren

Copy link
Copy Markdown
Collaborator

No description provided.

…e query for every custom field on show_bug.cgi, including fields that aren't tracking flags

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.

🟡 Changes recommended

The name-cache fast path can override an explicitly supplied ID, causing the same lookup to return different flags depending on whether the cache is populated.

1 open issue
What changed in this PR

This PR reduces database queries during tracking-flag permission checks on show_bug.cgi, particularly for custom fields that are not tracking flags.

Changes:

  • Skip non-tracking custom fields using a request-cached name set.
  • Reuse cached tracking flags for name lookups, with database fallback.
  • Add tests for cached lookups, cache changes, and permission-check filtering.
File Description
extensions/​TrackingFlags/​t/​flag-cache-by-name.t Tests name caching and non-tracking-field filtering.
extensions/​TrackingFlags/​lib/​Flag.pm Adds a request-cache index for flag lookups by name.
extensions/​TrackingFlags/​Extension.pm Filters non-tracking fields before constructing flag objects.

Review effort: Balanced

Comment thread extensions/TrackingFlags/lib/Flag.pm Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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.

🟢 Approval recommended

No active review issues are reported for the tracking-flag caching and permission-check changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@dklawren
dklawren requested review from Xzzz and cgsheeh November 11, 2026 22:00
my $a = flag(1, 'cf_status_firefox140');
new_request(a => $a);
is($FLAG->new(1), exact_ref($a), 'cached by id');
is(scalar @db_lookups, 0, 'no database lookups');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copilot's id precedence fix has no test, this fails if the !defined $param->{id} check is removed:

Suggested change
is(scalar @db_lookups, 0, 'no database lookups');
is(scalar @db_lookups, 0, 'no database lookups');
is($FLAG->new({id => 2, name => 'cf_status_firefox140'}),
undef, 'id wins over a cached name');
is(scalar @db_lookups, 1, 'id lookup went to the database');

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added in 22ecdb4. The new assertions fail if the !defined $param->{id} guard is removed.

@Xzzz Xzzz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, Thanks!
Just one optional test suggestion in flag-cache-by-name.t

dklawren and others added 2 commits November 12, 2026 10:23
…hed names

Addresses review feedback: covers the !defined $param->{id} guard in Flag->new.
@dklawren
dklawren merged commit 5d48fa1 into mozilla:master Nov 12, 2026
7 checks passed
@dklawren
dklawren deleted the 2091444 branch November 12, 2026 16:16
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.

3 participants