dealy14 / LearningFox-LMS

0 stars 0 forks source link

Possible race condition when adding a new course #66

Open jstuckle opened 12 years ago

jstuckle commented 12 years ago

When a course is added, the system gets the id by getting the maximum course id value in the table and adding 1 to it. This has several problems, such as:

  1. A race condition can occur when two or more people are adding courses concurrently. Both could be assigned the same value.
  2. Deleting the highest numbered course in the table will cause that course number to be reused - potentially causing confusion with users who had signed up (or taken) the original course.
  3. The location of the course's files are in /uploads/course-ID, where "ID" is the course number. A failed import may not properly clean up files in this directory, yet the course number will not be entered into the database. This means the next course to be added can get its files mixed up with the original course's files.

Resolution: The system should use an auto_increment field to assign the course id.