Skip to content

Commit f5f5bf2

Browse files
committed
bugfix: insert into table only if it does not yet exist
1 parent 4fdddc0 commit f5f5bf2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

step/adminapprove/lib.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,16 @@ public function process_course($processid, $instanceid, $course) {
5656
$record = new \stdClass();
5757
$record->processid = $processid;
5858
$record->status = 0;
59-
$DB->insert_record('lifecyclestep_adminapprove', $record);
59+
$status = $DB->get_field('lifecyclestep_adminapprove', 'status', ['processid' => $processid]);
60+
if ($status === false) {
61+
// Insert only if it does not exist.
62+
$DB->insert_record('lifecyclestep_adminapprove', $record);
63+
}
6064
self::$newcourses++;
6165
return step_response::waiting();
6266
}
6367

68+
6469
/**
6570
* Rollback a course.
6671
* @param int $processid

step/adminapprove/version.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2025050400;
27+
$plugin->version = 2025050400.01;
2828
$plugin->component = 'lifecyclestep_adminapprove';
2929
$plugin->requires = 2022112800; // Requires Moodle 4.1+.
3030
$plugin->supported = [401, 405];
3131
$plugin->release = 'v4.5-r1';
3232
$plugin->maturity = MATURITY_STABLE;
33+

0 commit comments

Comments
 (0)