Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-69194

core_user_update_users silently fails when updating email to an already existing one

    XMLWordPrintable

Details

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • master_MDL-69194-core_user_update_users
    • Hide

      Requires the admin to have a web service set up for users updating

      1) Create user1 with email foo@bar.com;
      2) Create user2 with email pee@wee.com;
      3) Enable web services and configure a third user with proper permissions (problem occurs even if this user is a site administrator);
      4) Call WS function core_user_update_users() to change user2's email to foo@bar.com.
      5) Make sure the function now returns an array of warnings, the array contains the item with a 'duplicate email' message for user2 and his id.

      Show
      Requires the admin to have a web service set up for users updating 1) Create user1 with email foo@bar.com; 2) Create user2 with email pee@wee.com; 3) Enable web services and configure a third user with proper permissions (problem occurs even if this user is a site administrator); 4) Call WS function core_user_update_users() to change user2's email to foo@bar.com. 5) Make sure the function now returns an array of warnings, the array contains the item with a 'duplicate email' message for user2 and his id.

    Description

      WS function core_user_update_users() fails to update a user's email attribute when the new email is already assigned to another user.  I understand this is the default behaviour for a brand new Moodle instance, but the problem is, it doesn't return any error message or exception.  I can successfully update other attributes such as firstname and password, so I believe it's not an issue with permissions or my programming.

      Steps to reproduce:
      1) Create user1 with email foo@bar.com;
      2) Create user2 with email pee@wee.com;
      3) Enable web services and configure a third user with proper permissions (problem occurs even if this user is a site administrator);
      4) Call WS function core_user_update_users() to change user2's email to foo@bar.com.

      What I expected:
      User2's email is not changed and WS call returns an error like "duplicate email" or "invalid parameter".

      What actually happens:
      User2's email is not changed and WS call returns nothing.

      Attachments

        Activity

          People

            mattp@catalyst-au.net Matt Porritt
            rafaelavila Rafael Avila
            Ilya Tregubov Ilya Tregubov
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona), Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona)
            Votes:
            2 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              19/Apr/22

              Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 36 minutes
                4h 36m