make $sql_query persistent (init it, never unset it, always assume it is set)

This commit is contained in:
Sebastian Mendel
2007-04-01 09:26:14 +00:00
parent 0848d0f654
commit b2f3ae5fcf
19 changed files with 46 additions and 58 deletions

View File

@@ -27,7 +27,7 @@ if (!empty($sql_query)) {
$GLOBALS['reload'] = true; $GLOBALS['reload'] = true;
} }
unset($sql_query); $sql_query = '';
} elseif (!empty($sql_localfile)) { } elseif (!empty($sql_localfile)) {
// run SQL file on server // run SQL file on server
$local_import_file = $sql_localfile; $local_import_file = $sql_localfile;

View File

@@ -549,10 +549,6 @@ class PMA_Table {
{ {
global $err_url; global $err_url;
if (! isset($GLOBALS['sql_query'])) {
$GLOBALS['sql_query'] = '';
}
// set export settings we need // set export settings we need
$GLOBALS['sql_backquotes'] = 1; $GLOBALS['sql_backquotes'] = 1;
$GLOBALS['asfile'] = 1; $GLOBALS['asfile'] = 1;
@@ -694,7 +690,6 @@ class PMA_Table {
unset($GLOBALS['sql_constraints_query']); unset($GLOBALS['sql_constraints_query']);
} }
} }
} else { } else {
$GLOBALS['sql_query'] = ''; $GLOBALS['sql_query'] = '';
} }

View File

@@ -426,7 +426,7 @@ if (PMA_isValid($_REQUEST['table'])) {
* sql query to be executed * sql query to be executed
* @global string $GLOBALS['sql_query'] * @global string $GLOBALS['sql_query']
*/ */
$GLOBALS['sql_query'] = null; $GLOBALS['sql_query'] = '';
if (PMA_isValid($_REQUEST['sql_query'])) { if (PMA_isValid($_REQUEST['sql_query'])) {
$GLOBALS['sql_query'] = $_REQUEST['sql_query']; $GLOBALS['sql_query'] = $_REQUEST['sql_query'];
} }

View File

@@ -985,7 +985,7 @@ function PMA_showMessage($message, $sql_query = null)
// Checks if the table needs to be repaired after a TRUNCATE query. // Checks if the table needs to be repaired after a TRUNCATE query.
// @todo what about $GLOBALS['display_query']??? // @todo what about $GLOBALS['display_query']???
// @todo this is REALLY the wrong place to do this - very unexpected here // @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'])) { && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
if (!isset($tbl_status)) { if (!isset($tbl_status)) {
$result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\''); $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\'');

View File

@@ -24,7 +24,7 @@ if (empty($is_db)) {
if (isset($message)) { if (isset($message)) {
$url_params['message'] = $message; $url_params['message'] = $message;
} }
if (isset($sql_query)) { if (! empty($sql_query)) {
$url_params['sql_query'] = $sql_query; $url_params['sql_query'] = $sql_query;
} }
if (isset($show_as_php)) { if (isset($show_as_php)) {
@@ -72,7 +72,7 @@ if (empty($is_table) && !defined('PMA_SUBMIT_MULT')) {
if (isset($message)) { if (isset($message)) {
$url_params['message'] = $message; $url_params['message'] = $message;
} }
if (isset($sql_query)) { if (! empty($sql_query)) {
$url_params['sql_query'] = $sql_query; $url_params['sql_query'] = $sql_query;
} }
if (isset($display_query)) { if (isset($display_query)) {

View File

@@ -60,7 +60,7 @@ if (isset($single_table)) {
echo '<input type="hidden" name="export_type" value="' . $export_type . '" />' . "\n"; 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 '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n";
} }
echo PMA_pluginGetJavascript($export_list); echo PMA_pluginGetJavascript($export_list);

View File

@@ -1246,7 +1246,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$transform_options['wrapper_link'] = '?' $transform_options['wrapper_link'] = '?'
. (isset($url_query) ? $url_query : '') . (isset($url_query) ? $url_query : '')
. '&amp;primary_key=' . (isset($unique_condition) ? $unique_condition : '') . '&amp;primary_key=' . (isset($unique_condition) ? $unique_condition : '')
. '&amp;sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '') . '&amp;sql_query=' . (empty($sql_query) ? '' : urlencode($url_sql_query))
. '&amp;goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '') . '&amp;goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '')
. '&amp;transform_key=' . urlencode($meta->name); . '&amp;transform_key=' . urlencode($meta->name);

View File

@@ -88,7 +88,7 @@ if (window.parent.reload_querywindow) {
window.parent.reload_querywindow( window.parent.reload_querywindow(
'<?php echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) ?>', '<?php echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) ?>',
'<?php echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) ?>', '<?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 <?php
} }

View File

@@ -74,7 +74,7 @@ function PMA_sqlQueryForm($query = true, $display_tab = false, $delimiter = ';')
// query to show // query to show
if (true === $query) { if (true === $query) {
$query = empty($GLOBALS['sql_query']) ? '' : $GLOBALS['sql_query']; $query = $GLOBALS['sql_query'];
} }
// set enctype to multipart for file uploads // set enctype to multipart for file uploads

View File

@@ -135,7 +135,7 @@ if ($GLOBALS['cfg']['PropertiesIconic']) {
$url_query = PMA_generate_common_url($db, $table); $url_query = PMA_generate_common_url($db, $table);
if (PMA_isValid($sql_query)) { if (! empty($sql_query)) {
$show_query = 1; $show_query = 1;
} }
@@ -160,7 +160,7 @@ if (! empty($show_query)) {
} else { } else {
$query_to_display = ''; $query_to_display = '';
} }
unset($sql_query); $sql_query = '';
/** /**
* start HTML output * start HTML output

View File

@@ -66,7 +66,6 @@ function PMA_generateEngineDetails($variables, $like = null) {
} }
} }
PMA_DBI_free_result($res); PMA_DBI_free_result($res);
unset($res, $row, $sql_query);
} }
if (empty($mysql_vars)) { if (empty($mysql_vars)) {

View File

@@ -724,7 +724,7 @@ if (!empty($change_copy)) {
* (Changes / copies a user, part II) * (Changes / copies a user, part II)
*/ */
if (!empty($adduser_submit) || !empty($change_copy)) { if (!empty($adduser_submit) || !empty($change_copy)) {
unset($sql_query); $sql_query = '';
if ($pred_username == 'any') { if ($pred_username == 'any') {
$username = ''; $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'; $sql_query = 'SELECT * FROM `mysql`.`db`' . $user_host_condition . ' ORDER BY `Db` ASC';
$res = PMA_DBI_query( $sql_query ); $res = PMA_DBI_query( $sql_query );
unset( $sql_query ); $sql_query = '';
while ( $row = PMA_DBI_fetch_assoc( $res ) ) { while ( $row = PMA_DBI_fetch_assoc( $res ) ) {
if ( isset( $db_rights[$row['Db']] ) ) { if ( isset( $db_rights[$row['Db']] ) ) {
@@ -1792,7 +1792,7 @@ if ( empty( $adduser ) && ( ! isset( $checkprivs ) || ! strlen($checkprivs) ) )
. $user_host_condition . $user_host_condition
.' ORDER BY `Table_name` ASC;'; .' ORDER BY `Table_name` ASC;';
$res = PMA_DBI_query( $sql_query ); $res = PMA_DBI_query( $sql_query );
unset( $sql_query ); $sql_query = '';
while ( $row = PMA_DBI_fetch_assoc( $res ) ) { while ( $row = PMA_DBI_fetch_assoc( $res ) ) {
if ( isset( $db_rights[$row['Table_name']] ) ) { if ( isset( $db_rights[$row['Table_name']] ) ) {

View File

@@ -57,7 +57,7 @@ if (isset($fields['dbase'])) {
// Default to browse if no query set an we have table // Default to browse if no query set an we have table
// (needed for browsing from DefaultTabTable) // (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'; require_once './libraries/bookmark.lib.php';
$book_sql_query = PMA_queryBookmarks($db, $book_sql_query = PMA_queryBookmarks($db,
$GLOBALS['cfg']['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', $GLOBALS['cfg']['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'',
@@ -228,13 +228,6 @@ if ($do_confirm) {
} // end if $do_confirm } // end if $do_confirm
/**
* Executes the query and displays results
*/
if (!isset($sql_query)) {
$sql_query = '';
}
// Defines some variables // Defines some variables
// A table has to be created or renamed -> left frame should be reloaded // A table has to be created or renamed -> left frame should be reloaded
/** /**

View File

@@ -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="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="dontlimitchars" value="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
<input type="hidden" name="err_url" value="<?php echo htmlspecialchars($err_url); ?>" /> <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 <?php
if (isset($primary_key_array)) { if (isset($primary_key_array)) {
foreach ($primary_key_array as $primary_key) { foreach ($primary_key_array as $primary_key) {
@@ -270,7 +270,7 @@ $url_params['table'] = $table;
if (isset($primary_key)) { if (isset($primary_key)) {
$url_params['primary_key'] = trim($primary_key); $url_params['primary_key'] = trim($primary_key);
} }
if (isset($sql_query)) { if (! empty($sql_query)) {
$url_params['sql_query'] = $sql_query; $url_params['sql_query'] = $sql_query;
} }

View File

@@ -231,7 +231,7 @@ if (isset($_REQUEST['do_save_data'])) {
. htmlspecialchars(PMA_backquote($db) . '.' . PMA_backquote($table)) . htmlspecialchars(PMA_backquote($db) . '.' . PMA_backquote($table))
. ' ' . $strHasBeenCreated; . ' ' . $strHasBeenCreated;
$display_query = $sql_query; $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 // do not switch to sql.php - as there is no row to be displayed on a new table
if ($cfg['DefaultTabTable'] === 'sql.php') { if ($cfg['DefaultTabTable'] === 'sql.php') {

View File

@@ -24,7 +24,7 @@ $export_page_title = $strViewDump;
// When we have some query, we need to remove LIMIT from that and possibly // 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) // 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 // Parse query so we can work with tokens
$parsed_sql = PMA_SQP_parse($sql_query); $parsed_sql = PMA_SQP_parse($sql_query);

View File

@@ -212,7 +212,7 @@ if (isset($_REQUEST['destination_innodb'])) {
} }
} // end if... else.... } // end if... else....
if (isset($sql_query)) { if (! empty($sql_query)) {
$upd_rs = PMA_DBI_try_query($sql_query); $upd_rs = PMA_DBI_try_query($sql_query);
$tmp_error = PMA_DBI_getError(); $tmp_error = PMA_DBI_getError();
if (! empty($tmp_error)) { if (! empty($tmp_error)) {
@@ -227,7 +227,8 @@ if (isset($_REQUEST['destination_innodb'])) {
echo '<p class="warning">' . $strForeignKeyError . ' : ' . $master_field echo '<p class="warning">' . $strForeignKeyError . ' : ' . $master_field
.'</p>' . PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n"; .'</p>' . PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
} }
unset($sql_query, $tmp_error); unset($tmp_error);
$sql_query = '';
} }
} // end foreach } // end foreach
if (!empty($display_query)) { if (!empty($display_query)) {

View File

@@ -127,7 +127,7 @@ if (!empty($submit_mult)) {
* Show result of multi submit operation * Show result of multi submit operation
*/ */
// sql_query is not set when user does not confirm multi-delete // 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_message = $strSuccess;
$disp_query = $sql_query; $disp_query = $sql_query;
} }