diff --git a/ChangeLog b/ChangeLog index 6d3b3d951..898adf90b 100755 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ $Source$ * libraries/sqlvalidator.class.php3: - Removed dependency on overload extension - Started to fix bug #644709 + * sql.php3, libraries/common.lib.php3, libraries/sqlparser.lib.php3: + - Revert line 88 of sql.php3, and fix it a different way... 2002-01-12 Robin Johnson * read_dump.php3, sql.php3, libraries/common.lib.php3, diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index c786b66f2..c595d5555 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -277,6 +277,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} // Check that we actually have a valid set of parsed data // well, not quite + // first check for the SQL parser having hit an error + if (PMA_SQP_isError()) { + return $parsed_sql; + } + // then check for an array if (!is_array($parsed_sql)) { // We don't so just return the input directly // This is intended to be used for when the SQL Parser is turned off @@ -323,8 +328,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} $is_modify_link = TRUE, $back_url = '') { global $cfg; - global $SQP_errorString; - + if (empty($GLOBALS['is_header_sent'])) { include('./header.inc.php3'); } @@ -338,7 +342,8 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} // --- Added to solve bug #641765 // Robbat2 - 12 January 2003, 9:46PM - if (isset($SQP_errorString) && !empty($SQP_errorString)) { + // Revised, Robbat2 - 13 Janurary 2003, 2:59PM + if (PMA_SQP_isError()) { $parsed_sql = $the_query; } else { $parsed_sql = PMA_SQP_parse($the_query); @@ -352,9 +357,9 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} if (!empty($the_query) && !strstr($the_query, 'connect')) { // --- Added to solve bug #641765 // Robbat2 - 12 January 2003, 9:46PM - if (isset($SQP_errorString) && !empty($SQP_errorString)) { - flush(); - echo $SQP_errorString; + // Revised, Robbat2 - 13 Janurary 2003, 2:59PM + if (PMA_SQP_isError()) { + echo PMA_SQP_getErrorString(); } // --- echo '

' . "\n"; diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index 427df4bf3..bcfa1ac87 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -72,23 +72,62 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { /** - * Do display an error message + * Reset the error variable for the SQL parser + * + * @access public + */ + // Added, Robbat2 - 13 Janurary 2003, 2:59PM + function PMA_SQP_resetError() { + global $SQP_errorString; + $SQP_errorString = ''; + unset($SQP_errorString); + } + + /** + * Get the contents of the error variable for the SQL parser + * + * @return string Error string from SQL parser + * + * @access public + */ + // Added, Robbat2 - 13 Janurary 2003, 2:59PM + function PMA_SQP_getErrorString() { + global $SQP_errorString; + return isset($SQP_errorString) ? $SQP_errorString : ''; + } + + /** + * Check if the SQL parser hit an error + * + * @return boolean error state + * + * @access public + */ + // Added, Robbat2 - 13 Janurary 2003, 2:59PM + function PMA_SQP_isError() { + global $SQP_errorString; + return isset($SQP_errorString) && !empty($SQP_errorString); + } + + /** + * Set an error message for the system * * @param string The error message * @param string The failing SQL query * - * @access public + * @access private + * @scope SQL Parser internal */ + // Revised, Robbat2 - 13 Janurary 2003, 2:59PM function PMA_SQP_throwError($message, $sql) { - $debugstr = 'ERROR: ' . $message . "\n"; - $debugstr .= 'SQL: ' . $sql; global $SQP_errorString; $SQP_errorString = '

'.$GLOBALS['strSQLParserUserError'] . '

' . "\n" - . '
' . "\n"
-             . $debugstr . "\n"
-             . '
' . "\n"; + . '
' . "\n"
+            . 'ERROR: ' . $message . "\n"
+            . 'SQL: ' . $sql .  "\n"
+            . '
' . "\n"; /* // Removed to solve bug #641765 - Robbat2 - 12 January 2003, 9:46PM @@ -1119,6 +1158,15 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { */ function PMA_SQP_formatHtml($arr, $mode='color') { + // first check for the SQL parser having hit an error + if (PMA_SQP_isError()) { + return $arr; + } + // then check for an array + if (!is_array($arr)) { + return $arr; + } + // else do it properly switch ($mode) { case 'color': $str = ''; diff --git a/sql.php3 b/sql.php3 index eddaf5f7b..4bb17e1d6 100755 --- a/sql.php3 +++ b/sql.php3 @@ -86,7 +86,8 @@ if (isset($btnDrop) || isset($navig)) { $parsed_sql = PMA_SQP_parse((get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query)); $analyzed_sql = PMA_SQP_analyze($parsed_sql); // Bug #641765 - Robbat2 - 12 January 2003, 10:49PM -//$sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only'); +// Reverted - Robbat2 - 13 January 2003, 2:40PM +$sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only'); // here we are sure that SELECT is uppercase $is_select = eregi('^SELECT[[:space:]]+', $sql_query);