From 1860955f39cc98e8752f03e7f05684d77a795bff Mon Sep 17 00:00:00 2001 From: Julien Boulen Date: Sun, 12 Oct 2025 21:35:03 +0200 Subject: [PATCH] MDL-83543 core: Move download complete status handling to Excel library When a form is validated, all validation buttons are automatically locked to prevent them from being sent twice by mistake. When the form returns a file instead of redirecting to a new HTML page, a mechanism (\core_form\util::form_download_complete()) must be called to reactivate the form's validation buttons. This mechanism is called for CSV files (file lib/csvlib.class.php), but not when downloading xls files. The mechanism is only called when downloading grades in Excel format (file grade/export/xls/grade_export_xls.php). The patch proposes to call this mechanism globally for all Excel file downloads (file lib/excellib.class.php), and not just for grade downloads (file grade/export/xls/grade_export_xls.php). --- public/grade/export/xls/grade_export_xls.php | 3 --- public/lib/excellib.class.php | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/grade/export/xls/grade_export_xls.php b/public/grade/export/xls/grade_export_xls.php index ec4bbcd2d15..f81b0e25846 100644 --- a/public/grade/export/xls/grade_export_xls.php +++ b/public/grade/export/xls/grade_export_xls.php @@ -45,9 +45,6 @@ class grade_export_xls extends grade_export { $strgrades = get_string('grades'); - // If this file was requested from a form, then mark download as complete (before sending headers). - \core_form\util::form_download_complete(); - // Calculate file name $shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id))); $downloadfilename = clean_filename("$shortname $strgrades.xls"); diff --git a/public/lib/excellib.class.php b/public/lib/excellib.class.php index ff300752c77..812535df4ed 100644 --- a/public/lib/excellib.class.php +++ b/public/lib/excellib.class.php @@ -110,6 +110,9 @@ class MoodleExcelWorkbook { public function close() { global $CFG; + // If this file was requested from a form, then mark download as complete. + \core_form\util::form_download_complete(); + foreach ($this->objspreadsheet->getAllSheets() as $sheet) { $sheet->setSelectedCells('A1'); }