mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
Prevent race condition in event creation. MDL-5956.
Credit goes to Penny, Luke and Martin @ Catalyst. Merged from MOODLE_17_STABLE
This commit is contained in:
parent
757bc06941
commit
d0a2161941
2 changed files with 22 additions and 18 deletions
|
@ -212,13 +212,14 @@
|
|||
if (count($err) == 0) {
|
||||
$form->timemodified = time();
|
||||
|
||||
if ($form->repeat) {
|
||||
$fetch = get_record_sql('SELECT 1, MAX(repeatid) AS repeatid FROM '.$CFG->prefix.'event');
|
||||
$form->repeatid = empty($fetch) ? 1 : $fetch->repeatid + 1;
|
||||
}
|
||||
|
||||
/// Get the event id for the log record.
|
||||
$eventid = insert_record('event', $form, true);
|
||||
|
||||
/// Use the event id as the repeatid to link repeat entries together
|
||||
if ($form->repeat) {
|
||||
$form->repeatid = $form->id = $eventid;
|
||||
update_record('event', $form); // update the row, to set its repeatid
|
||||
}
|
||||
|
||||
/// Log the event entry.
|
||||
add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&id='.$eventid, stripslashes($form->name));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue