Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1446236 - BugmailFilter: Divorce from TrackingFlags extension #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CyberShadow
Copy link
Member

Allow BugmailFilter extension to work without TrackingFlags.

# remove all tracking flag fields (from the TrackingFlags extension).
# these change too frequently to be of value,
# so they only add noise to the list.
state $have_tracking_flags = any { $_->NAME eq 'TrackingFlags' } @{ Bugzilla->extensions };
Copy link

Choose a reason for hiding this comment

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

Why not instead have $tracking_flag_names which is an array-ref, and in boolean terms could be @$tracking_flag_names? That would be even more efficient.

Otherwise I approve this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Bugzilla::has_extension is now in git, so I'll update this to use it instead.

I think we want to eventually refactor all uses of has_extension out of core and instead provide hooks or equivalent functionality to allow extending the core in an extension-agnostic way. Using has_extension thus creates an implicit TODO, but we could use it alongside some other method, like a comment, instead.

I'm also a bit nervous about the idea of enabling execution of some non-trivial logic (which happens to be a no-op when the array is empty) by a boolean condition with dual meaning (disabled whether the array is empty or doesn't exist, if I understood you correctly).

Copy link

Choose a reason for hiding this comment

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

I'm not sure I see any difference between a boolean array, and a boolean flag. Your logic above is setting a boolean flag based on whether anything is in the array, then repeatedly getting the contents of such an array on every call?

Copy link
Member Author

Choose a reason for hiding this comment

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

Your logic above is setting a boolean flag based on whether anything is in the array, then repeatedly getting the contents of such an array on every call?

Sorry, could you please clarify what this is referring to specifically?

Copy link

Choose a reason for hiding this comment

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

Literally the line we're commenting on. To copy-paste it:

state $have_tracking_flags = any { $_->NAME eq 'TrackingFlags' } @{ Bugzilla->extensions };

That is a boolean flag. Its truth depends on whether the array in Bugzilla->extensions contains any whose name is TrackingFlags. Does that return a different list from Bugzilla->tracking_flag_names?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for clarifying.

That is a boolean flag. Its truth depends on whether the array in Bugzilla->extensions contains any whose name is TrackingFlags.

Yep, the plan is to remove that line, and replace if ($have_tracking_flags) with if (Bugzilla->has_extension('TrackingFlags')).

Does that return a different list from Bugzilla->tracking_flag_names?

Well, that depends. Can Bugzilla->tracking_flag_names ever return an empty array? If yes, then the change becomes more than a simple refactoring, and the semantic meaning of the check is changed: it is now overloaded to mean both "Bugzilla->tracking_flag_names doesn't exist" and "Bugzilla->tracking_flag_names exists, but returned an empty array".

I hope I understood the situation correctly.

Copy link

Choose a reason for hiding this comment

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

I would have thought having the array-ref be empty (and still using whether it has content for the boolean) so you can use it in that array-boolean rather than reference-boolean, which this sort of is.

@CyberShadow CyberShadow force-pushed the bugmailfilter-wo-trackingflags branch from 0876c18 to 3a4736d Compare June 7, 2020 23:25
@CyberShadow CyberShadow changed the base branch from unstable to master June 7, 2020 23:26
Base automatically changed from master to main February 13, 2021 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants