Skip to content

Commit

Permalink
Merge branch 'QA_4_1'
Browse files Browse the repository at this point in the history
  • Loading branch information
lem9 committed Dec 19, 2013
2 parents 207466d + 7cfc603 commit fd943ed
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -11,6 +11,7 @@ phpMyAdmin - ChangeLog

4.1.2.0 (not yet released)
- bug #4178 Quick edit for BIT type does not work
- bug #2760 Warn about incomplete exports

4.1.1.0 (2013-12-17)
- bug #4154 Error using UNION query
Expand Down
32 changes: 29 additions & 3 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 it's 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";
}
exit;
}
/**
* Sets globals from $_POST
*
Expand Down Expand Up @@ -247,7 +258,7 @@
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;
Expand All @@ -256,6 +267,21 @@
$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")) {
//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
*
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
4 changes: 3 additions & 1 deletion js/messages.php
Expand Up @@ -413,7 +413,9 @@
$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

0 comments on commit fd943ed

Please sign in to comment.