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

Simultaneous mod_assign_save_user_extensions calls generate duplicate data in assign_user_flags table

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.11.6
    • None
    • Assignment, Web Services
    • None
    • MOODLE_311_STABLE

    Description

      Simultaneous calls via webservices API to mod_assign_save_user_extensions causes duplicate data entries in assign_user_flags table. Generally these don't cause a problem, but both data entries are returned by mod_assign_get_user_flags webservices API.

      To reproduce:

      1. Make two simultaneous calls to: siteurl/webservice/rest/server.php?token&moodlewsrestformat=json&wsfunction=mod_assign_save_user_extensions&assignmentid=assignmentid&userids[0]=userid&dates[0]=1639656000
      2. Make a call to siteurl/webservice/rest/server.php?token&moodlewsrestformat=json&wsfunction=mod_assign_get_user_flags&assignmentids[0]=assignmentid. You will see two entries return for userid. Only the first entry is actually 'live' and kept in line with workflow status, extension date, etc. changes within Moodle.
      3. Run SQL SELECT * FROM prefix_assign_user_flags WHERE assignment = assignmentid and userid = userid and you will see two entries. There should just be one.

      To fix, you should probably add database locking to the mod_assign_save_user_extensions function to prevent duplicate data being created.

      If that isn't easy then as a starter you could prevent mod_assign_get_user_flags from returning the defunct entry.

      Attachments

        Activity

          People

            Unassigned Unassigned
            JohnPercival John Percival
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: