From d3fc01713120fa1875c447daff94f2afc404dd3d Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 19 Dec 2013 06:26:18 -0500 Subject: [PATCH] Code cleanup Signed-off-by: Marc Delisle --- export.php | 26 ++++++++++++++++---------- js/export.js | 14 +++++++------- js/messages.php | 4 +++- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/export.php b/export.php index 3004dd5d4a..70aecccdbf 100644 --- a/export.php +++ b/export.php @@ -21,16 +21,16 @@ if (!defined('TESTSUITE')) { include_once 'libraries/zip.lib.php'; include_once 'libraries/plugin_interface.lib.php'; - //check if its the GET request to check export time out + //check if it's the GET request to check export time out if (isset($_GET['check_time_out'])) { - if(isset($_SESSION['pma_export_error'])) { + if (isset($_SESSION['pma_export_error'])) { $err = $_SESSION['pma_export_error']; unset($_SESSION['pma_export_error']); echo $err; } else { echo "success"; } - return; + exit; } /** * Sets globals from $_POST @@ -266,15 +266,21 @@ if (!defined('TESTSUITE')) { // We send fake headers to avoid browser timeout when buffering $time_start = time(); } + +/** + * Sets a session variable upon a possible fatal error during export + * + * @return void + */ function PMA_shutdown() { - $a = error_get_last(); - if ($a != null && strpos($a['message'], "execution time")) { - //writting in partially downloaded file for future reference of user - print_r($a); - //set session variable to check if there was error while exporting - $_SESSION['pma_export_error'] = $a['message']; - } + $a = error_get_last(); + if ($a != null && strpos($a['message'], "execution time")) { + //write in partially downloaded file for future reference of user + print_r($a); + //set session variable to check if there was error while exporting + $_SESSION['pma_export_error'] = $a['message']; + } } /** * Detect ob_gzhandler diff --git a/js/export.js b/js/export.js index 04901b1889..a16bd29221 100644 --- a/js/export.js +++ b/js/export.js @@ -216,7 +216,7 @@ function toggle_quick_or_custom() var time_out; function check_time_out(time_limit) { - //margin of one second to avoid race condition to set/access session variable + //margin of one second to avoid race condition to set/access session variable time_limit = time_limit + 1; var href = "export.php"; var params = { @@ -227,16 +227,16 @@ function check_time_out(time_limit) clearTimeout(time_out); time_out = setTimeout(function(){ $.get(href, params, function (data) { - if(data['message'] !== 'success') { + if (data['message'] !== 'success') { PMA_ajaxShowMessage( - '
' + - PMA_messages.strTimeOutError + - '
', - false + '
' + + PMA_messages.strTimeOutError + + '
', + false ); } }); - },time_limit*1000); + }, time_limit * 1000); } AJAX.registerOnload('export.js', function () { diff --git a/js/messages.php b/js/messages.php index 4f28c68b47..9c9a8bd436 100644 --- a/js/messages.php +++ b/js/messages.php @@ -413,7 +413,9 @@ $js_messages['strErrorOccurred'] = __( $js_messages['strChangeReportSettings'] = __("Change Report Settings"); $js_messages['strShowReportDetails'] = __("Show Report Details"); $js_messages['strIgnore'] = __("Ignore"); -$js_messages['strTimeOutError'] = __("Your export is incomplete, due to a low execution time limit at the PHP level"); +$js_messages['strTimeOutError'] = __( + "Your export is incomplete, due to a low execution time limit at the PHP level" +); echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { PMA_printJsValue("PMA_messages['" . $name . "']", $js_message);