From 845a370d6f2c062e84b8869d5badee3ffd3f5dfe Mon Sep 17 00:00:00 2001 From: Guillaume <139738084+gbarat87@users.noreply.github.com> Date: Wed, 3 Dec 2025 16:40:42 +1000 Subject: [PATCH] Fix #314: Switch optional_param starttime to optional_param_array (#384) * Fix #314: Switch optional_param starttime to optional_param_array * convert default startime to timestamp * fix error debug warning --- edit.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/edit.php b/edit.php index eebb285..f4812e8 100644 --- a/edit.php +++ b/edit.php @@ -48,7 +48,24 @@ if ($mform->is_cancelled()) { $clone = optional_param('clone', 0, PARAM_INT); $edit = optional_param('edit', 0, PARAM_INT); -$time = optional_param('starttime', 0, PARAM_INT); +if (array_key_exists('starttime', $_POST) && is_array($_POST['starttime'])) { + $start = optional_param_array('starttime', [], PARAM_INT); +} else { + $start = optional_param('starttime', 0, PARAM_INT); +} +if (!empty($start['year']) && !empty($start['month']) && !empty($start['day'])) { + $hour = $start['hour'] ?? 0; + $minute = $start['minute'] ?? 0; + $time = make_timestamp( + (int) $start['year'], + (int) $start['month'], + (int) $start['day'], + (int) $hour, + (int) $minute + ); +} else { + $time = 0; +} if ($clone && $edit) { throw new invalid_parameter_exception('Cannot provide both clone and edit ids.'); }