-
-
Notifications
You must be signed in to change notification settings - Fork 30
[Bug 1963773][Harmony] login-names separate from email addresses #147
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
base: main
Are you sure you want to change the base?
Changes from all commits
5b19a7d
9126b93
e9cdb7a
b4e10d8
43a5566
880d9ae
3ceeed9
1ba09fa
9a54d04
4205bd7
6a0758f
f638667
a3add95
c785e57
de4807e
24f7283
5e52941
67674b8
a4be2f2
574d95b
d92a37a
bb4399f
edf8b6d
6b1e064
0ccb69d
03a91d6
8676091
d3fded1
e49fe87
40df3f2
3bc163b
26c7dda
3256359
ca84658
0b8dadd
ba60296
24c1366
f54b3cf
884c21f
503010f
3d53c25
35ddd05
d54ed69
bb53674
393eb9d
0bd16d3
50b6e71
2a3a8a3
0a34409
177fc27
e4ca9a4
8f4e0ab
ec0ffab
dcc01f6
c6ff94d
f4847f8
567860a
5cd3cb6
adf2201
58bde1b
4b0e7dc
0d7d7fb
7c60d17
5e2c5f7
13ace61
c8c2e96
1f32d29
01400e4
528f4c1
410cecc
d6a216a
6202e37
91f7d0d
ca3054c
27a5c4a
816bdf7
dbf8e7d
4e82f4c
dd7e441
e452a75
9b01505
c705a05
0f705a9
4e5d7e9
c400a97
e93b725
320ae8a
1c8af66
565af33
ac3abe2
13eca3d
f4f2070
f951015
077be0c
da852f6
6262b97
7d6638b
b4e4a2e
01f6477
1e69387
02779c7
bae60f8
9d3824b
43e65a4
8621cfa
0363a1f
a6ee967
93457d1
87be5dd
c2852ab
e33ec45
1880bfe
87821d3
229d922
afb5970
f66c89d
587df9e
6fa78fb
9436f2a
7d74000
3809beb
ae26661
8390ba6
e745356
00555af
3a4c851
c20dea8
78b2d7e
03008ad
e5cc69c
90c6c4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -832,7 +832,8 @@ sub update_table_definitions { | |
|
|
||
| _populate_attachment_storage_class(); | ||
|
|
||
|
|
||
| # Bug 1963773 - topunixguy@gmail.com | ||
| _copy_valid_emails_to_profiles_emails(); | ||
| ################################################################ | ||
| # New --TABLE-- changes should go *** A B O V E *** this point # | ||
| ################################################################ | ||
|
|
@@ -4387,6 +4388,61 @@ sub _populate_attachment_storage_class { | |
| } | ||
| } | ||
|
|
||
| sub _copy_valid_emails_to_profiles_emails { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not 100% sure if this is an issue or not as I'm not sure how good we've been in the past about validating emails and whether we could have invalid emails in the database already that are also valid accounts but: Migration silently drops users with no valid email or login-as-email - if neither profiles.email nor login_name passes validate_email_syntax(), the loop does next unless defined $valid_email — that user ends up with zero rows in profiles_emails, no warning logged. This PR's own history explicitly adds support for non-email logins, meaning the users most likely to trigger this are exactly the ones the feature targets. Downstream, User::email() (User.pm:652) silently falls back to returning the login string in place of an email with no indication anything's wrong (notifications, password-reset lookups, etc. would then act on a non-email login string). Separately, individual insert failures in this same function are caught and only warn()ed — a one-time schema migration should fail loudly, not swallow errors. |
||
| my $dbh = Bugzilla->dbh; | ||
|
|
||
| my ($total) = $dbh->selectrow_array("SELECT COUNT(*) FROM profiles"); | ||
| unless ($total) { | ||
| print "Skipping profiles_emails population: no profiles to process.\n"; | ||
| return; | ||
| } | ||
|
|
||
| # Check if 'email' column exists in 'profiles' | ||
| my $has_email_column = $dbh->bz_column_info('profiles', 'email') ? 1 : 0; | ||
|
|
||
| # Build SELECT statement dynamically | ||
| my $select_sql = 'SELECT userid, login_name'; | ||
| $select_sql .= ', email' if $has_email_column; | ||
| $select_sql .= ' FROM profiles'; | ||
|
|
||
| my $select_sth = $dbh->prepare($select_sql); | ||
| my $check_sth = $dbh->prepare('SELECT 1 FROM profiles_emails WHERE user_id = ?'); | ||
| my $insert_sth = $dbh->prepare(' | ||
| INSERT INTO profiles_emails (user_id, email, is_primary_email, display_order) | ||
| VALUES (?, ?, 1, 1) | ||
| '); | ||
|
|
||
| $select_sth->execute(); | ||
|
|
||
| while (my $row = $select_sth->fetchrow_hashref) { | ||
| my $user_id = $row->{userid}; | ||
|
|
||
| # Skip if the user already has an entry | ||
| $check_sth->execute($user_id); | ||
| next if $check_sth->fetchrow_array; | ||
|
|
||
| my $email = $has_email_column ? $row->{email} : undef; | ||
| my $login = $row->{login_name}; | ||
|
|
||
| my $valid_email; | ||
| if (defined $email && $email ne '' && validate_email_syntax($email)) { | ||
| $valid_email = $email; | ||
| } elsif (defined $login && $login ne '' && validate_email_syntax($login)) { | ||
| $valid_email = $login; | ||
| } | ||
|
|
||
| next unless defined $valid_email; | ||
|
|
||
| eval { | ||
| $insert_sth->execute($user_id, $valid_email); | ||
| }; | ||
| warn "Failed to insert email for user $user_id: $@" if $@; | ||
| } | ||
|
|
||
| $select_sth->finish; | ||
| $check_sth->finish; | ||
| $insert_sth->finish; | ||
| } | ||
|
|
||
| 1; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-PR Bugzilla/Auth/Verify.pm synced $user->set_login($username) when an external auth source (LDAP/SAML/etc.) reported a changed username for an existing account. I diffed against the pre-PR commit and confirmed this branch was deleted and replaced with email-only sync. Sites relying on external auth to keep login names current will silently stop getting that update.