Commit 9f1f94ff authored by Robert Lyon's avatar Robert Lyon Committed by Cecilia Vela Gurovic
Browse files

Bug 1757330: PHP 7.1 is not keeping the session when exporting



We do a bunch of iframe / js tricks to get the progress bar to work
and then rely on session for the file name to serve it at the end

This change just passes only the file name to the js redirect and then
rebuilds the full path on return. Because we use the user's id in full
path we can make sure only the valid logged in user can fetch the file

behatnotneeded

Change-Id: I6478df19465ad8e1075343cb40e6f5360061b56a
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit ba36e509)
parent 18e5acaa
......@@ -14,7 +14,9 @@ require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('docroot') . '/lib/htmloutput.php');
// Download the export file if it's been generated
if ($exportfile = $SESSION->get('exportfile')) {
$downloadfile = param_variable('file', null);
if ($downloadfile) {
$exportfile = get_config('dataroot') . 'export/' . $USER->get('id') . '/' . $downloadfile;
$SESSION->set('exportdata', '');
$SESSION->set('exportfile', '');
require_once('file.php');
......@@ -104,6 +106,7 @@ try {
// the download. Here it would be nice to trigger the download for everyone,
// but alas this is not possible for people without javascript.
$SESSION->set('exportfile', $exporter->get('exportdir') . $zipfile);
$filepath = str_replace(get_config('dataroot') . 'export/' . $USER->get('id') . '/', '', $exporter->get('exportdir') . $zipfile);
$continueurl = 'download.php';
$continueurljs = get_config('wwwroot') . 'export/index.php';
$result = $SESSION->get('messages');
......@@ -114,4 +117,4 @@ else {
$SESSION->clear('messages');
$strexport = get_string('exportgeneratedwitherrors', 'export');
}
print_export_footer($strexport, $continueurl, $continueurljs, $result, 'download.php');
print_export_footer($strexport, $continueurl, $continueurljs, $result, get_config('wwwroot') . 'export/download.php?file=' . $filepath);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment