Upload CSV Users Bug with Failed Emails

Bug #1958499 reported by Ghada El-Zoghbi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Unassigned
20.10
Fix Released
High
Unassigned
21.04
Fix Released
High
Unassigned
21.10
Fix Released
High
Unassigned
22.04
Fix Released
High
Unassigned

Bug Description

Mahara: 21.10.0
OS: Linux 20.04
DB: Postgres
Browser: n/a

While implementing a customisation for a client, we identified a very old bug in htdocs/admin/users/uploadcsv.php.

The setting of the `$failedusers` array on line 639 occurs within the foreach loop. Which means, the data in the $failedusers array gets reset after each iteration.

The initialisation of $failedusers should occur outside of the foreach loop.

https://github.com/MaharaProject/mahara/blob/main/htdocs/admin/users/uploadcsv.php#L644-L667

This is the current code at line 637:

if ($values['emailusers'] && $addedusers) {
        foreach ($addedusers as $user) {
            $failedusers = array();
            try {
            ...

It should be:

if ($values['emailusers'] && $addedusers) {
        $failedusers = array(); <- MOVE outside the foreach loop
        foreach ($addedusers as $user) {
            try {
            ...

Hope that makes sense.

Thank you.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "main" branch: https://reviews.mahara.org/12367

Revision history for this message
Robert Lyon (robertl-9) wrote :
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/12367
Committed: https://git.mahara.org/mahara/mahara/commit/0e8e1151460b2d1dbc9ea54187b8ba53c0201c97
Submitter: Robert Lyon (<email address hidden>)
Branch: main

commit 0e8e1151460b2d1dbc9ea54187b8ba53c0201c97
Author: Ghada El-Zoghbi <email address hidden>
Date: Fri Jan 21 09:04:46 2022 +1300

Bug 1958499: Failed user upload csv email problem

The accumulated failed users array is not being set correctly
as it resets on every loop

Change-Id: Ic1f7abf0197bad29502c6f651dacf19c8c41e320
Signed-off-by: Robert Lyon <email address hidden>

Robert Lyon (robertl-9)
Changed in mahara:
status: New → Fix Committed
milestone: none → 22.04.0
importance: Undecided → High
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "21.10_DEV" branch: https://reviews.mahara.org/12368

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "21.04_DEV" branch: https://reviews.mahara.org/12369

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "20.10_DEV" branch: https://reviews.mahara.org/12370

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/12369
Committed: https://git.mahara.org/mahara/mahara/commit/22881152547656b8bf7835d71e1d4b2b0f15acc1
Submitter: Robert Lyon (<email address hidden>)
Branch: 21.04_DEV

commit 22881152547656b8bf7835d71e1d4b2b0f15acc1
Author: Ghada El-Zoghbi <email address hidden>
Date: Fri Jan 21 09:04:46 2022 +1300

Bug 1958499: Failed user upload csv email problem

The accumulated failed users array is not being set correctly
as it resets on every loop

Change-Id: Ic1f7abf0197bad29502c6f651dacf19c8c41e320
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit 0e8e1151460b2d1dbc9ea54187b8ba53c0201c97)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/12368
Committed: https://git.mahara.org/mahara/mahara/commit/b824ab045af93ac31e639e0317e563f7a80900f6
Submitter: Robert Lyon (<email address hidden>)
Branch: 21.10_DEV

commit b824ab045af93ac31e639e0317e563f7a80900f6
Author: Ghada El-Zoghbi <email address hidden>
Date: Fri Jan 21 09:04:46 2022 +1300

Bug 1958499: Failed user upload csv email problem

The accumulated failed users array is not being set correctly
as it resets on every loop

Change-Id: Ic1f7abf0197bad29502c6f651dacf19c8c41e320
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit 0e8e1151460b2d1dbc9ea54187b8ba53c0201c97)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/12370
Committed: https://git.mahara.org/mahara/mahara/commit/1487803c87aae138bc27445b15a7849e10ec67c3
Submitter: Robert Lyon (<email address hidden>)
Branch: 20.10_DEV

commit 1487803c87aae138bc27445b15a7849e10ec67c3
Author: Ghada El-Zoghbi <email address hidden>
Date: Fri Jan 21 09:04:46 2022 +1300

Bug 1958499: Failed user upload csv email problem

The accumulated failed users array is not being set correctly
as it resets on every loop

Change-Id: Ic1f7abf0197bad29502c6f651dacf19c8c41e320
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit 0e8e1151460b2d1dbc9ea54187b8ba53c0201c97)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.