← Back to team overview

mahara-contributors team mailing list archive

[Bug 1966138] A change has been merged

 

Reviewed:  https://reviews.mahara.org/c/mahara/+/12623
Committed: https://git.mahara.org/mahara/mahara/commit/f98dd60c57eef228c55a3cd3364438571c460170
Submitter: "Robert Lyon <robertl@xxxxxxxxxxxxxxx>"
Branch:    21.10_DEV

commit f98dd60c57eef228c55a3cd3364438571c460170
Author: Robert Lyon <robertl@xxxxxxxxxxxxxxx>
Date:   Thu Mar 24 11:32:59 2022 +1300

Bug 1966138: Better seting of email profile field

Normally when we use set_profile_field() to set an email it will make
the existing primary email be renamed to the new one.
But if you already have a secondary email with the same value then
things go wrong as it tries to set your existing primary to the new
value rather than just make the secondary one the primary one

Change-Id: Ia82c24c7f8e18eaac8c5c7cfd648c6a4b50ec3c0
Signed-off-by: Robert Lyon <robertl@xxxxxxxxxxxxxxx>

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: mahara-contributors
https://bugs.launchpad.net/bugs/1966138

Title:
  The set_profile_field() function for email doesn't check for doubleups

Status in Mahara:
  Fix Committed
Status in Mahara 20.10 series:
  Fix Committed
Status in Mahara 21.04 series:
  Fix Committed
Status in Mahara 21.10 series:
  Fix Committed
Status in Mahara 22.04 series:
  Fix Committed

Bug description:
  If I have an account where there is only one email address and I call
  the set_profile_field() to update the account to a new email address,
  eg set_profile_field($userid, 'email', $newemail);

  It will update the person to have the new email address as their
  primary address.

  However, if I have the situation where the person already has two addresses, say:
  e1@xxxxxxxxxxx and e2@xxxxxxxxxxx where e1@xxxxxxxxxxx is the primary email

   id | artefact_email | artefact_id | artefact_internal_profile_email | principal 
  ----+----------------+-------------+---------------------------------+-----------
    7 | e1@xxxxxxxxxxx |           7 | e1@xxxxxxxxxxx                  |         1
    8 | e2@xxxxxxxxxxx |           8 | e2@xxxxxxxxxxx                  |         0

  and I try to update the email via set_profile_field($userid, 'email', 'e2@xxxxxxxxxxx');
  the function fetches the primary address one and tries to update it to the new address and I end up with:

  
   id | artefact_email | artefact_id | artefact_internal_profile_email | principal 
  ----+----------------+-------------+---------------------------------+-----------
    7 | e2@xxxxxxxxxxx |           7 | e1@xxxxxxxxxxx                  |         1
    8 | e2@xxxxxxxxxxx |           8 | e2@xxxxxxxxxxx                  |         0

  Where there is a mismatch on the primary email line.

  We need the set_profile_field() for email to check that the email
  value we are setting the primary email to doesn't already exist for
  this person as one of their secondary emails

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1966138/+subscriptions



References