Skip to content

Commit

Permalink
bug fix #2760
Browse files Browse the repository at this point in the history
Signed-off-by: Smita Kumari <kumarismita62@gmail.com>
  • Loading branch information
smita786 committed Dec 18, 2013
1 parent 887cd2b commit 675e457
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 8 deletions.
28 changes: 24 additions & 4 deletions export.php
Expand Up @@ -14,13 +14,24 @@
* If we are sending the export file (as opposed to just displaying it
* as text), we have to bypass the usual PMA_Response mechanism
*/
if ($_POST['output_format'] == 'sendit') {
if (isset($_POST['output_format']) && $_POST['output_format'] == 'sendit') {
define('PMA_BYPASS_GET_INSTANCE', 1);
}
include_once 'libraries/common.inc.php';
include_once 'libraries/zip.lib.php';
include_once 'libraries/plugin_interface.lib.php';


//check if its the GET request to check export time out
if (isset($_GET['check_time_out'])) {
if(isset($_SESSION['pma_export_error'])) {
$err = $_SESSION['pma_export_error'];
unset($_SESSION['pma_export_error']);
echo $err;
} else {
echo "success";
}
return;
}
/**
* Sets globals from $_POST
*
Expand Down Expand Up @@ -247,15 +258,24 @@
if (! empty($cfg['MemoryLimit'])) {
@ini_set('memory_limit', $cfg['MemoryLimit']);
}

register_shutdown_function('PMA_shutdown');
// Start with empty buffer
$dump_buffer = '';
$dump_buffer_len = 0;

// We send fake headers to avoid browser timeout when buffering
$time_start = time();
}

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'];
}
}
/**
* Detect ob_gzhandler
*
Expand Down
27 changes: 26 additions & 1 deletion js/export.js
Expand Up @@ -213,7 +213,32 @@ function toggle_quick_or_custom()
$("#output_quick_export").show();
}
}

var time_out;
function check_time_out(time_limit)
{
//margin of one second to avoid race condition to set/access session variable
time_limit = time_limit + 1;
var href = "export.php";
var params = {
'ajax_request' : true,
'token' : PMA_commonParams.get('token'),
'check_time_out' : true
};
clearTimeout(time_out);
time_out = setTimeout(function(){
$.get(href, params, function (data) {
if(data['message'] !== 'success') {
PMA_ajaxShowMessage(
'<div class="error">' +
PMA_messages.strTimeOutError +
'</div>',
false
);
}
});
},time_limit*1000);

}
AJAX.registerOnload('export.js', function () {
$("input[type='radio'][name='quick_or_custom']").change(toggle_quick_or_custom);

Expand Down
2 changes: 1 addition & 1 deletion js/messages.php
Expand Up @@ -413,7 +413,7 @@
$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");
echo "var PMA_messages = new Array();\n";
foreach ($js_messages as $name => $js_message) {
PMA_printJsValue("PMA_messages['" . $name . "']", $js_message);
Expand Down
4 changes: 2 additions & 2 deletions libraries/display_export.lib.php
Expand Up @@ -290,8 +290,8 @@ function PMA_getHtmlForExportOptionsFormat($export_list)
$html .= PMA_Util::getExternalBug(
__('SQL compatibility mode'), 'mysql', '50027', '14515'
);

$html .= '<input type="submit" value="' . __('Go') . '" id="buttonGo" />';
global $cfg;
$html .= '<input type="submit" value="' . __('Go') . '" id="buttonGo" onclick="check_time_out('.$cfg['ExecTimeLimit'].')"/>';
$html .= '</div>';

return $html;
Expand Down

2 comments on commit 675e457

@lem9
Copy link
Contributor

@lem9 lem9 commented on 675e457 Apr 6, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Smita,
do you have an idea about this bug:
https://sourceforge.net/p/phpmyadmin/bugs/4346/

@smita786
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, let me look into it. Sorry for the delayed reply, I was out of town.

Please sign in to comment.