Skip to content

Bug 2085398 - Read flag changes from flag_activity and stop writing them to bugs_activity - #2796

Open
Xzzz wants to merge 57 commits into
mozilla:masterfrom
Xzzz:bug-2085398
Open

Xzzz wants to merge 57 commits into
mozilla:masterfrom
Xzzz:bug-2085398

Conversation

@Xzzz

@Xzzz Xzzz commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Stops writing flag changes to bugs_activity: new ones are only recorded in flag_activity, and everything that reads flag changes now reads both tables, bugs_activity for the changes up to the cutoff stored by checksetup and flag_activity for the later ones.

Part 2 of 1806896, whose part 1 (#2657) moved flag_state_activity to core as flag_activity and writes every flag change to both tables. The schema part (#2830) is already deployed, so this PR has no schema change.

Changes

  • Bugzilla::Bug, Bugzilla::Attachment and the user deletion in editusers.cgi no longer log flagtypes.name to bugs_activity.
  • Bug history (GetBugActivity), bugmail (_get_diffs), the BMO user activity report and the UserProfile per-product counts read the flagtypes.name rows in bugs_activity up to the cutoff and the flag_activity rows after it (Bugzilla::FlagActivity->cutoff). A change written to both tables, by a pod still on the older code, is listed once. A request that changes a flag several times shows its net change, compared with the flag's last row before the request.
  • Search changedbefore/changedafter/changedfrom/changedto/changedby/everchanged on flags, and the ReleaseTracking report, match either table.
  • The BugModal activity stream finds a flag's last change by its flag_id in flag_activity.
  • The other readers of a user's activity also read flag_activity: the non-bot last change time, the UserProfile stats, the TagNewUsers first activity, owner idle time, and changed* searches on any field.
  • A flag type that has flag_activity rows can only be deactivated, not deleted, as its history would be deleted with it. The user deletion check in editusers.cgi counts flag_activity rows.
  • New tests: t/flag-activity-history.t, -search.t, -user-stats.t, -stream.t and t/flag-type-delete.t; t/flag-activity-start-rows.t checks the history around the starting rows.

The old flagtypes.name rows stay in bugs_activity. Nothing is deleted.

Deploy

No checksetup step: the cutoff is the one stored when #2830 was deployed. During the rolling deploy, pods still on the older code read only bugs_activity, so they miss the flag changes made on the new pods until they are replaced.

Test plan

  • Set a needinfo, a review on an attachment and an approval flag, then clear one: bug history, the activity stream and the bugmail show each change with its previous state, and bugs_activity gets no new flagtypes.name row
  • Redirect a needinfo to someone else as another user: history shows that user
  • On a bug with flag changes from before the deploy: history shows them once, with their previous state
  • Search "Flags changed to needinfo?" and the user activity report find both older and new changes
  • Delete a user with pending requests in editusers.cgi: the cleared requests appear in bug history
  • Delete a flag type that was used: only deactivation is offered

References

@Xzzz

Xzzz commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Please note that the test_sanity critic failure is the $$ on master fixed by #2795. I'll re-run CI once it's merged, it should go green, unless I missed stg ;)

@Xzzz
Xzzz requested a review from dklawren October 23, 2026 19:06
Comment thread Bugzilla/Bug.pm Resolved
Comment thread Bugzilla/Bug.pm Resolved
Comment thread Bugzilla/Bug.pm Resolved
Comment thread Bugzilla/Bug.pm Resolved
@Xzzz
Xzzz requested a review from dklawren October 27, 2026 17:05
Comment thread Bugzilla/Bug.pm Resolved
Comment thread Bugzilla/DB/Schema.pm Resolved
Comment thread editusers.cgi Resolved
Comment thread editusers.cgi Resolved
@Xzzz
Xzzz requested a review from dklawren October 29, 2026 21:27
Comment thread Bugzilla/DB/Schema.pm Resolved
Comment thread Bugzilla/Bug.pm Resolved
Comment thread Bugzilla/Search.pm Resolved
@Xzzz
Xzzz requested a review from dklawren November 3, 2026 22:03
Comment thread Bugzilla/Install/DB.pm Resolved
Comment thread Bugzilla/FlagActivity.pm Resolved
Xzzz added 3 commits November 5, 2026 16:23
# Conflicts:
#	Bugzilla/DB/Schema.pm
#	Bugzilla/Install/DB.pm
#	t/flag-activity-who.t
@Xzzz
Xzzz requested a review from dklawren November 5, 2026 17:27
Comment thread Bugzilla/Bug.pm Resolved
Comment thread Bugzilla/BugMail.pm Resolved
Comment thread Bugzilla/BugMail.pm Resolved
Comment thread Bugzilla/Search.pm Resolved
@Xzzz

Xzzz commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Besides the 5 previous points, found 4 small things, fixed in separate commits:

  • ff7a278: the owner idle time search counted flag_activity rows up to the cutoff, whose who is a guess (changedby and the others already skip them) + new case in t/flag-activity-search.t
  • 7ba522f: the release tracking report now only counts the net change of a request, like history
  • 259baba: find_activity_id_for_flag uses sql_limit instead of a raw LIMIT 1
  • 262c8aa: stale comments in Flag.pm (flags tracked in bugs_activity) and Install/DB.pm (who still nullable)

I also merged master: extensions/Needinfo/t/bmo/mentions-on-create.t (from #2809) looked for the needinfo set when filing in bugs_activity, it now reads flag_activity.
Merging also pushed ProhibitComplexMappings over the critic baseline, so three map blocks of this PR are now loops.

Comment thread Bugzilla/Bug.pm Resolved
@Xzzz

Xzzz commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

As agreed, the schema part of this PR is split out to #2830 (flag_activity.who NOT NULL, the starting rows and the cutoff table), which runs on the current code.
This PR stays on hold until #2830 is deployed, I'll then merge master into it, so its diff only keeps the code changes.

@dklawren

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

# Conflicts:
#	Bugzilla/DB/Schema.pm
#	Bugzilla/Install/DB.pm
#	Bugzilla/Test/Util.pm
#	editusers.cgi
#	qa/t/4_test_user_delete_requestee.t
#	t/flag-activity-start-rows.t
#	t/flag-activity-who.t
@Xzzz

Xzzz commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

#2830 is deployed, so I merged master into this PR: its diff now only has the code changes.
One change on the way: master makes flag_activity.requestee_id ON DELETE SET NULL (from #2830), so I dropped this PR's refusal to delete a user who is a requestee in the flag history (editusers.cgi, confirm-delete template and its selenium test). Master's test, which checks that such a user can be deleted, replaces it.

This branch has not been deployed

No deployments
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