make $sql_query persistent (init it, never unset it, always assume it is set)
This commit is contained in:
@@ -27,7 +27,7 @@ if (!empty($sql_query)) {
|
||||
$GLOBALS['reload'] = true;
|
||||
}
|
||||
|
||||
unset($sql_query);
|
||||
$sql_query = '';
|
||||
} elseif (!empty($sql_localfile)) {
|
||||
// run SQL file on server
|
||||
$local_import_file = $sql_localfile;
|
||||
|
@@ -549,10 +549,6 @@ class PMA_Table {
|
||||
{
|
||||
global $err_url;
|
||||
|
||||
if (! isset($GLOBALS['sql_query'])) {
|
||||
$GLOBALS['sql_query'] = '';
|
||||
}
|
||||
|
||||
// set export settings we need
|
||||
$GLOBALS['sql_backquotes'] = 1;
|
||||
$GLOBALS['asfile'] = 1;
|
||||
@@ -581,7 +577,7 @@ class PMA_Table {
|
||||
require_once './libraries/export/sql.php';
|
||||
|
||||
$no_constraints_comments = true;
|
||||
$GLOBALS['sql_constraints_query'] = '';
|
||||
$GLOBALS['sql_constraints_query'] = '';
|
||||
|
||||
$sql_structure = PMA_getTableDef($source_db, $source_table, "\n", $err_url);
|
||||
unset($no_constraints_comments);
|
||||
@@ -606,22 +602,22 @@ class PMA_Table {
|
||||
}
|
||||
|
||||
/* no need to PMA_backquote() */
|
||||
if (isset($target_for_view)) {
|
||||
// this a view definition; we just found the first db name
|
||||
// that follows DEFINER VIEW
|
||||
// so change it for the new db name
|
||||
$parsed_sql[$i]['data'] = $target_for_view;
|
||||
// then we have to find all references to the source db
|
||||
// and change them to the target db, ensuring we stay into
|
||||
// the $parsed_sql limits
|
||||
$last = $parsed_sql['len'] - 1;
|
||||
$backquoted_source_db = PMA_backquote($source_db);
|
||||
for (++$i; $i <= $last; $i++) {
|
||||
if ($parsed_sql[$i]['type'] == 'quote_backtick' && $parsed_sql[$i]['data'] == $backquoted_source_db) {
|
||||
if (isset($target_for_view)) {
|
||||
// this a view definition; we just found the first db name
|
||||
// that follows DEFINER VIEW
|
||||
// so change it for the new db name
|
||||
$parsed_sql[$i]['data'] = $target_for_view;
|
||||
}
|
||||
}
|
||||
unset($last,$backquoted_source_db);
|
||||
// then we have to find all references to the source db
|
||||
// and change them to the target db, ensuring we stay into
|
||||
// the $parsed_sql limits
|
||||
$last = $parsed_sql['len'] - 1;
|
||||
$backquoted_source_db = PMA_backquote($source_db);
|
||||
for (++$i; $i <= $last; $i++) {
|
||||
if ($parsed_sql[$i]['type'] == 'quote_backtick' && $parsed_sql[$i]['data'] == $backquoted_source_db) {
|
||||
$parsed_sql[$i]['data'] = $target_for_view;
|
||||
}
|
||||
}
|
||||
unset($last,$backquoted_source_db);
|
||||
} else {
|
||||
$parsed_sql[$i]['data'] = $target;
|
||||
}
|
||||
@@ -660,7 +656,7 @@ class PMA_Table {
|
||||
// find the first quote_backtick, it must be the source table name
|
||||
while ($parsed_sql[$i]['type'] != 'quote_backtick') {
|
||||
$i++;
|
||||
// maybe someday we should guard against going over limit
|
||||
// maybe someday we should guard against going over limit
|
||||
//if ($i == $parsed_sql['len']) {
|
||||
// break;
|
||||
//}
|
||||
@@ -686,15 +682,14 @@ class PMA_Table {
|
||||
// Generate query back
|
||||
$GLOBALS['sql_constraints_query'] = PMA_SQP_formatHtml($parsed_sql,
|
||||
'query_only');
|
||||
if ($mode == 'one_table') {
|
||||
if ($mode == 'one_table') {
|
||||
PMA_DBI_query($GLOBALS['sql_constraints_query']);
|
||||
}
|
||||
}
|
||||
$GLOBALS['sql_query'] .= "\n" . $GLOBALS['sql_constraints_query'];
|
||||
if ($mode == 'one_table') {
|
||||
if ($mode == 'one_table') {
|
||||
unset($GLOBALS['sql_constraints_query']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$GLOBALS['sql_query'] = '';
|
||||
}
|
||||
|
@@ -426,7 +426,7 @@ if (PMA_isValid($_REQUEST['table'])) {
|
||||
* sql query to be executed
|
||||
* @global string $GLOBALS['sql_query']
|
||||
*/
|
||||
$GLOBALS['sql_query'] = null;
|
||||
$GLOBALS['sql_query'] = '';
|
||||
if (PMA_isValid($_REQUEST['sql_query'])) {
|
||||
$GLOBALS['sql_query'] = $_REQUEST['sql_query'];
|
||||
}
|
||||
|
@@ -985,7 +985,7 @@ function PMA_showMessage($message, $sql_query = null)
|
||||
// Checks if the table needs to be repaired after a TRUNCATE query.
|
||||
// @todo what about $GLOBALS['display_query']???
|
||||
// @todo this is REALLY the wrong place to do this - very unexpected here
|
||||
if (strlen($GLOBALS['table']) && isset($GLOBALS['sql_query'])
|
||||
if (strlen($GLOBALS['table'])
|
||||
&& $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
|
||||
if (!isset($tbl_status)) {
|
||||
$result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');
|
||||
|
@@ -24,7 +24,7 @@ if (empty($is_db)) {
|
||||
if (isset($message)) {
|
||||
$url_params['message'] = $message;
|
||||
}
|
||||
if (isset($sql_query)) {
|
||||
if (! empty($sql_query)) {
|
||||
$url_params['sql_query'] = $sql_query;
|
||||
}
|
||||
if (isset($show_as_php)) {
|
||||
@@ -72,7 +72,7 @@ if (empty($is_table) && !defined('PMA_SUBMIT_MULT')) {
|
||||
if (isset($message)) {
|
||||
$url_params['message'] = $message;
|
||||
}
|
||||
if (isset($sql_query)) {
|
||||
if (! empty($sql_query)) {
|
||||
$url_params['sql_query'] = $sql_query;
|
||||
}
|
||||
if (isset($display_query)) {
|
||||
|
@@ -60,7 +60,7 @@ if (isset($single_table)) {
|
||||
|
||||
echo '<input type="hidden" name="export_type" value="' . $export_type . '" />' . "\n";
|
||||
|
||||
if (isset($sql_query)) {
|
||||
if (! empty($sql_query)) {
|
||||
echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n";
|
||||
}
|
||||
echo PMA_pluginGetJavascript($export_list);
|
||||
|
@@ -1246,7 +1246,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
|
||||
$transform_options['wrapper_link'] = '?'
|
||||
. (isset($url_query) ? $url_query : '')
|
||||
. '&primary_key=' . (isset($unique_condition) ? $unique_condition : '')
|
||||
. '&sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '')
|
||||
. '&sql_query=' . (empty($sql_query) ? '' : urlencode($url_sql_query))
|
||||
. '&goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '')
|
||||
. '&transform_key=' . urlencode($meta->name);
|
||||
|
||||
|
@@ -88,7 +88,7 @@ if (window.parent.reload_querywindow) {
|
||||
window.parent.reload_querywindow(
|
||||
'<?php echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) ?>',
|
||||
'<?php echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) ?>',
|
||||
'<?php echo isset($GLOBALS['sql_query']) && ! defined('PMA_QUERY_TOO_BIG') ? PMA_escapeJsString($GLOBALS['sql_query']) : ''; ?>');
|
||||
'<?php echo ! defined('PMA_QUERY_TOO_BIG') ? PMA_escapeJsString($GLOBALS['sql_query']) : ''; ?>');
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
@@ -173,7 +173,7 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
|
||||
}
|
||||
// check length of query unless we decided to pass it to sql.php
|
||||
if (!$go_sql) {
|
||||
if ($cfg['VerboseMultiSubmit'] && !empty($sql_query)) {
|
||||
if ($cfg['VerboseMultiSubmit'] && ! empty($sql_query)) {
|
||||
if (strlen($sql_query) > 50000 || $executed_queries > 50 || $max_sql_len > 1000) {
|
||||
$sql_query = '';
|
||||
$sql_query_disabled = TRUE;
|
||||
|
@@ -74,7 +74,7 @@ function PMA_sqlQueryForm($query = true, $display_tab = false, $delimiter = ';')
|
||||
|
||||
// query to show
|
||||
if (true === $query) {
|
||||
$query = empty($GLOBALS['sql_query']) ? '' : $GLOBALS['sql_query'];
|
||||
$query = $GLOBALS['sql_query'];
|
||||
}
|
||||
|
||||
// set enctype to multipart for file uploads
|
||||
|
@@ -135,7 +135,7 @@ if ($GLOBALS['cfg']['PropertiesIconic']) {
|
||||
|
||||
$url_query = PMA_generate_common_url($db, $table);
|
||||
|
||||
if (PMA_isValid($sql_query)) {
|
||||
if (! empty($sql_query)) {
|
||||
$show_query = 1;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ if (! empty($show_query)) {
|
||||
} else {
|
||||
$query_to_display = '';
|
||||
}
|
||||
unset($sql_query);
|
||||
$sql_query = '';
|
||||
|
||||
/**
|
||||
* start HTML output
|
||||
|
@@ -66,7 +66,6 @@ function PMA_generateEngineDetails($variables, $like = null) {
|
||||
}
|
||||
}
|
||||
PMA_DBI_free_result($res);
|
||||
unset($res, $row, $sql_query);
|
||||
}
|
||||
|
||||
if (empty($mysql_vars)) {
|
||||
|
@@ -724,7 +724,7 @@ if (!empty($change_copy)) {
|
||||
* (Changes / copies a user, part II)
|
||||
*/
|
||||
if (!empty($adduser_submit) || !empty($change_copy)) {
|
||||
unset($sql_query);
|
||||
$sql_query = '';
|
||||
if ($pred_username == 'any') {
|
||||
$username = '';
|
||||
}
|
||||
@@ -1712,7 +1712,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
|
||||
|
||||
$sql_query = 'SELECT * FROM `mysql`.`db`' . $user_host_condition . ' ORDER BY `Db` ASC';
|
||||
$res = PMA_DBI_query( $sql_query );
|
||||
unset( $sql_query );
|
||||
$sql_query = '';
|
||||
|
||||
while ( $row = PMA_DBI_fetch_assoc( $res ) ) {
|
||||
if ( isset( $db_rights[$row['Db']] ) ) {
|
||||
@@ -1792,7 +1792,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
|
||||
. $user_host_condition
|
||||
.' ORDER BY `Table_name` ASC;';
|
||||
$res = PMA_DBI_query( $sql_query );
|
||||
unset( $sql_query );
|
||||
$sql_query = '';
|
||||
|
||||
while ( $row = PMA_DBI_fetch_assoc( $res ) ) {
|
||||
if ( isset( $db_rights[$row['Table_name']] ) ) {
|
||||
|
9
sql.php
9
sql.php
@@ -57,7 +57,7 @@ if (isset($fields['dbase'])) {
|
||||
|
||||
// Default to browse if no query set an we have table
|
||||
// (needed for browsing from DefaultTabTable)
|
||||
if (! isset($sql_query) && strlen($table) && strlen($db)) {
|
||||
if (empty($sql_query) && strlen($table) && strlen($db)) {
|
||||
require_once './libraries/bookmark.lib.php';
|
||||
$book_sql_query = PMA_queryBookmarks($db,
|
||||
$GLOBALS['cfg']['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'',
|
||||
@@ -228,13 +228,6 @@ if ($do_confirm) {
|
||||
} // end if $do_confirm
|
||||
|
||||
|
||||
/**
|
||||
* Executes the query and displays results
|
||||
*/
|
||||
if (!isset($sql_query)) {
|
||||
$sql_query = '';
|
||||
}
|
||||
|
||||
// Defines some variables
|
||||
// A table has to be created or renamed -> left frame should be reloaded
|
||||
/**
|
||||
|
@@ -31,7 +31,7 @@ if (isset($_REQUEST['dontlimitchars'])) {
|
||||
$dontlimitchars = $_REQUEST['dontlimitchars'];
|
||||
}
|
||||
/**
|
||||
* @todo this one is badly named, it's really a WHERE condition
|
||||
* @todo this one is badly named, it's really a WHERE condition
|
||||
* and exists even for tables not having a primary key or unique key
|
||||
*/
|
||||
if (isset($_REQUEST['primary_key'])) {
|
||||
@@ -209,7 +209,7 @@ document.onkeydown = onKeyDownArrowsHandler;
|
||||
<input type="hidden" name="repeat_cells" value="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
|
||||
<input type="hidden" name="dontlimitchars" value="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
|
||||
<input type="hidden" name="err_url" value="<?php echo htmlspecialchars($err_url); ?>" />
|
||||
<input type="hidden" name="sql_query" value="<?php echo isset($sql_query) ? htmlspecialchars($sql_query) : ''; ?>" />
|
||||
<input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
|
||||
<?php
|
||||
if (isset($primary_key_array)) {
|
||||
foreach ($primary_key_array as $primary_key) {
|
||||
@@ -270,7 +270,7 @@ $url_params['table'] = $table;
|
||||
if (isset($primary_key)) {
|
||||
$url_params['primary_key'] = trim($primary_key);
|
||||
}
|
||||
if (isset($sql_query)) {
|
||||
if (! empty($sql_query)) {
|
||||
$url_params['sql_query'] = $sql_query;
|
||||
}
|
||||
|
||||
|
@@ -231,7 +231,7 @@ if (isset($_REQUEST['do_save_data'])) {
|
||||
. htmlspecialchars(PMA_backquote($db) . '.' . PMA_backquote($table))
|
||||
. ' ' . $strHasBeenCreated;
|
||||
$display_query = $sql_query;
|
||||
unset($sql_query);
|
||||
$sql_query = '';
|
||||
|
||||
// do not switch to sql.php - as there is no row to be displayed on a new table
|
||||
if ($cfg['DefaultTabTable'] === 'sql.php') {
|
||||
|
@@ -24,7 +24,7 @@ $export_page_title = $strViewDump;
|
||||
// When we have some query, we need to remove LIMIT from that and possibly
|
||||
// generate WHERE clause (if we are asked to export specific rows)
|
||||
|
||||
if (isset($sql_query)) {
|
||||
if (! empty($sql_query)) {
|
||||
// Parse query so we can work with tokens
|
||||
$parsed_sql = PMA_SQP_parse($sql_query);
|
||||
|
||||
|
@@ -212,7 +212,7 @@ if (isset($_REQUEST['destination_innodb'])) {
|
||||
}
|
||||
} // end if... else....
|
||||
|
||||
if (isset($sql_query)) {
|
||||
if (! empty($sql_query)) {
|
||||
$upd_rs = PMA_DBI_try_query($sql_query);
|
||||
$tmp_error = PMA_DBI_getError();
|
||||
if (! empty($tmp_error)) {
|
||||
@@ -227,7 +227,8 @@ if (isset($_REQUEST['destination_innodb'])) {
|
||||
echo '<p class="warning">' . $strForeignKeyError . ' : ' . $master_field
|
||||
.'</p>' . PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
|
||||
}
|
||||
unset($sql_query, $tmp_error);
|
||||
unset($tmp_error);
|
||||
$sql_query = '';
|
||||
}
|
||||
} // end foreach
|
||||
if (!empty($display_query)) {
|
||||
|
@@ -127,7 +127,7 @@ if (!empty($submit_mult)) {
|
||||
* Show result of multi submit operation
|
||||
*/
|
||||
// sql_query is not set when user does not confirm multi-delete
|
||||
if ((!empty($submit_mult) || isset($mult_btn)) && isset($sql_query)) {
|
||||
if ((!empty($submit_mult) || isset($mult_btn)) && ! empty($sql_query)) {
|
||||
$disp_message = $strSuccess;
|
||||
$disp_query = $sql_query;
|
||||
}
|
||||
|
Reference in New Issue
Block a user