Public bug reported:

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.

** Affects: mahara
     Importance: Undecided
         Status: New

-- 
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/1958499

Title:
  Upload CSV Users Bug with Failed Emails

Status in Mahara:
  New

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.

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


_______________________________________________
Mailing list: https://launchpad.net/~mahara-contributors
Post to     : mahara-contributors@lists.launchpad.net
Unsubscribe : https://launchpad.net/~mahara-contributors
More help   : https://help.launchpad.net/ListHelp

Reply via email to