mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #65839
[Bug 1966138] Re: The set_profile_field() function for email doesn't check for doubleups
Unable to replicate this issue. Multiple paths are possible to get to
the set_profile_field function. Some paths have may have their own
validation to prevent your issue before it gets to that point. Instead
of exhausting all the paths, I
```sql
select id as artefact_id, title as atefact_email, email, principal, verified FROM artefact
LEFT JOIN artefact_internal_profile_email ON artefact.id = artefact_internal_profile_email.artefact;
```
*STEP #1*: fresh site
artefact_id | atefact_email | email | principal | verified
-------------+--------------------------+--------------------------+-----------+----------
1 | doristam@xxxxxxxxxxxxxx | doristam@xxxxxxxxxxxxxx | 1 | 1
- - -
RESULT: one email and it is the primary
*STEP #2*: add an email with Curl to pass through `set_profile_field`
```bash
curl --location --request POST 'http://mahara/webservice/rest/server.php' \
--form 'wstoken="7349d3a2defb45d63216d1b415680897"' \
--form 'wsfunction="mahara_user_update_users"' \
--form 'users[0][id]="1"' \
--form 'users[0][email]="example@xxxxxxxxxxx"'
```
artefact_id | atefact_email | email | principal | verified
-------------+--------------------------+--------------------------+-----------+----------
1 | doristam@xxxxxxxxxxxxxx | doristam@xxxxxxxxxxxxxx | 0 | 1
6 | example@xxxxxxxxxxx | example@xxxxxxxxxxx | 1 | 1
- - -
RESULT: the email is added and becomes the primary
*Step #3*: In the UI, set doris as the primary again
artefact_id | atefact_email | email | principal | verified
-------------+--------------------------+--------------------------+-----------+----------
6 | example@xxxxxxxxxxx | example@xxxxxxxxxxx | 0 | 1
1 | doristam@xxxxxxxxxxxxxx | doristam@xxxxxxxxxxxxxx | 1 | 1
- - -
RESULT: doris is the primary email
*Step #4*: add the example email with Curl to pass through
`set_profile_field`
artefact_id | atefact_email | email | principal | verified
-------------+--------------------------+--------------------------+-----------+----------
1 | doristam@xxxxxxxxxxxxxx | doristam@xxxxxxxxxxxxxx | 0 | 1
6 | example@xxxxxxxxxxx | example@xxxxxxxxxxx | 1 | 1
- - -
RESULT: we don't go through `set_profile_field` but primary was given to the email...
ahh it's because update_user() calls set_user_primary_email() if the current email is not the same as current
so update_user() does both, set the email as primary + add it to the db
--
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:
In Progress
Status in Mahara 20.10 series:
In Progress
Status in Mahara 21.04 series:
In Progress
Status in Mahara 21.10 series:
In Progress
Status in Mahara 22.04 series:
In Progress
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