diff options
author | Sebastian Mendel <cybot_tm@users.sourceforge.net> | 2006-09-21 18:28:46 +0400 |
---|---|---|
committer | Sebastian Mendel <cybot_tm@users.sourceforge.net> | 2006-09-21 18:28:46 +0400 |
commit | 1eadc0a41a8173e019ff92f3ed41ab0ca7dc3025 (patch) | |
tree | f4fbd7f212c4be189a801438bbf3dd3b01d01764 | |
parent | ca44c117a29e60bbe7c33220e2f9a7b484b8d62a (diff) |
use @todo tag for todo items, to show up in generated documentation
31 files changed, 1030 insertions, 914 deletions
diff --git a/db_datadict.php b/db_datadict.php index b8bc9d76ea..77de08ed2c 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -42,7 +42,7 @@ if ($cfgRelation['commwork']) { */ if (is_array($comment)) { ?> - <p> <?php echo $strDBComment; ?> + <p> <?php echo $strDBComment; ?> <i><?php echo htmlspecialchars( implode( ' ', $comment ) ); ?></i></p> <?php } // end if @@ -168,7 +168,7 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) { /** * Displays the table structure */ - ?> + ?> <table width="100%" class="print"> <tr><th width="50"><?php echo $strField; ?></th> @@ -238,14 +238,16 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) { // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe // the latter. - // TODO: merge this logic with the one in tbl_properties_structure.php - // or move it in a function similar to PMA_DBI_get_columns_full() - // but based on SHOW CREATE TABLE because information_schema - // cannot be trusted in this case (MySQL bug) + /** + * @todo merge this logic with the one in tbl_properties_structure.php + * or move it in a function similar to PMA_DBI_get_columns_full() + * but based on SHOW CREATE TABLE because information_schema + * cannot be trusted in this case (MySQL bug) + */ if (!empty($analyzed_sql[0]['create_table_fields'][$field_name]['type']) && $analyzed_sql[0]['create_table_fields'][$field_name]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$field_name]['timestamp_not_null']) { $row['Null'] = ''; } - ?> + ?> <tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>"> <td nowrap="nowrap"> <?php @@ -254,7 +256,7 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) { } else { echo $field_name; } - ?> + ?> </td> <td<?php echo $type_nowrap; ?> xml:lang="en" dir="ltr"><?php echo $type; ?></td> <?php /* <td<?php echo $type_nowrap; ?>><?php echo $strAttribute; ?></td>*/ ?> @@ -291,7 +293,7 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) { } // end while PMA_DBI_free_result( $result ); $count++; - ?> + ?> </table> </div> <?php @@ -300,7 +302,7 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) { /** * Displays the footer */ -?> +?> <script type="text/javascript" language="javascript"> //<![CDATA[ function printPage() diff --git a/db_operations.php b/db_operations.php index 510ba63686..2f690df9c8 100644 --- a/db_operations.php +++ b/db_operations.php @@ -86,12 +86,13 @@ if (isset($db) && } unset($table); - // now that all tables exist, create all the accumulated constraints + // now that all tables exist, create all the accumulated constraints if (isset($GLOBALS['add_constraints'])) { - // FIXME: this works with mysqli but not with mysql, - // because mysql extension does not accept more than one - // statement; maybe interface with the sql import plugin - // that handles statement delimiter + /** + * @todo this works with mysqli but not with mysql, because + * mysql extension does not accept more than one statement; maybe + * interface with the sql import plugin that handles statement delimiter + */ PMA_DBI_query($GLOBALS['sql_constraints_query_full_db']); // and prepare to display them diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 042bcde426..402ade25cd 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -384,7 +384,7 @@ class PMA_Config } /** - * @TODO check validity of $_COOKIE['pma_collation_connection'] + * @todo check validity of $_COOKIE['pma_collation_connection'] */ if (! empty($_COOKIE['pma_collation_connection'])) { $this->set('collation_connection', @@ -657,7 +657,7 @@ class PMA_Config /** * check selected collation_connection - * @TODO check validity of $_REQUEST['collation_connection'] + * @todo check validity of $_REQUEST['collation_connection'] */ function checkCollationConnection() { diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 173c617003..45eca99797 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -215,6 +215,7 @@ class PMA_Table { * Checks if this "table" is a view * * @deprecated + * @todo see what we could do with the possible existence of $table_is_view * @param string the database name * @param string the table name * @@ -224,8 +225,6 @@ class PMA_Table { */ function _isView($db, $table) { // maybe we already know if the table is a view - // TODO: see what we could do with the possible existence - // of $table_is_view if (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view']) { return true; } @@ -244,6 +243,8 @@ class PMA_Table { * generates column/field specification for ALTER or CREATE TABLE syntax * * @todo move into class PMA_Column + * @todo on the interface, some js to clear the default value when the default + * current_timestamp is checked * @static * @param string $name name * @param string $type type ('INT', 'VARCHAR', 'BIT', ...) @@ -269,10 +270,10 @@ class PMA_Table { { // $default_current_timestamp has priority over $default - // TODO: on the interface, some js to clear the default value - // when the default current_timestamp is checked - // TODO: include db-name + /** + * @todo include db-name + */ $query = PMA_backquote($name) . ' ' . $type; if ($length != '' @@ -401,7 +402,7 @@ class PMA_Table { } // end of the 'PMA_Table::countRecords()' function /** - * @TODO add documentation + * @todo add documentation */ function generateAlter($oldcol, $newcol, $type, $length, $attribute, $collation, $null, $default, $default_current_timestamp, @@ -501,7 +502,7 @@ class PMA_Table { /** * Copies or renames table - * FIXME: use RENAME for move operations + * @todo use RENAME for move operations * - works only if the databases are on the same filesystem, * how can we check that? try the operation and * catch an error? @@ -524,7 +525,9 @@ class PMA_Table { // Ensure the target is valid if (! $GLOBALS['PMA_List_Database']->exists($source_db, $target_db)) { - // @TODO exit really needed here? or just a return? + /** + * @todo exit really needed here? or just a return? + */ exit; } @@ -716,10 +719,12 @@ class PMA_Table { unset($table_query); } - // garvin: [TODO] Can't get moving PDFs the right way. The page numbers always - // get screwed up independently from duplication because the numbers do not - // seem to be stored on a per-database basis. Would the author of pdf support - // please have a look at it? + /** + * @todo garvin: Can't get moving PDFs the right way. The page numbers + * always get screwed up independently from duplication because the + * numbers do not seem to be stored on a per-database basis. Would + * the author of pdf support please have a look at it? + */ if ($GLOBALS['cfgRelation']['pdfwork']) { $table_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['table_coords']) @@ -799,11 +804,13 @@ class PMA_Table { $new_fields = array('foreign_db' => $target_db, 'foreign_table' => $target_table); PMA_Table::duplicateInfo('relwork', 'relation', $get_fields, $where_fields, $new_fields); - // garvin: [TODO] Can't get duplicating PDFs the right way. The page numbers always - // get screwed up independently from duplication because the numbers do not - // seem to be stored on a per-database basis. Would the author of pdf support - // please have a look at it? - /* + /** + * @todo garvin: Can't get duplicating PDFs the right way. The + * page numbers always get screwed up independently from + * duplication because the numbers do not seem to be stored on a + * per-database basis. Would the author of pdf support please + * have a look at it? + * $get_fields = array('page_descr'); $where_fields = array('db_name' => $source_db); $new_fields = array('db_name' => $target_db); @@ -815,7 +822,7 @@ class PMA_Table { $new_fields = array('db_name' => $target_db, 'table_name' => $target_table, 'pdf_page_number' => $last_id); PMA_Table::duplicateInfo('pdfwork', 'table_coords', $get_fields, $where_fields, $new_fields); } - */ + */ } } @@ -893,8 +900,9 @@ class PMA_Table { $this->setName($new_name); $this->setDbName($new_db); - // TODO move into extra function - // PMA_Relation::renameTable($new_name, $old_name, $new_db, $old_db) + /** + * @todo move into extra function PMA_Relation::renameTable($new_name, $old_name, $new_db, $old_db) + */ // garvin: Move old entries from comments to new table require_once './libraries/relation.lib.php'; $GLOBALS['cfgRelation'] = PMA_getRelationsParam(); diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php index edf2269246..af82f16d7d 100644 --- a/libraries/auth/config.auth.lib.php +++ b/libraries/auth/config.auth.lib.php @@ -99,10 +99,12 @@ function PMA_auth_fails() echo "\n"; $GLOBALS['is_header_sent'] = TRUE; - //TODO: I have included this div from libraries/header.inc.php to work around - // an undefined variable in tooltip.js, when the server - // is not responding. Work has to be done to merge all code that - // starts the page (DOCTYPE and this div) to one place + /** + * @todo I have included this div from libraries/header.inc.php to work around + * an undefined variable in tooltip.js, when the server is not responding. + * Work has to be done to merge all code that starts the page (DOCTYPE and + * this div) to one place + */ ?> <div id="TooltipContainer" onmouseover="holdTooltip();" onmouseout="swapTooltip('default');"></div> <?php diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php index 04dfb0ec28..09d52c167c 100644 --- a/libraries/check_user_privileges.lib.php +++ b/libraries/check_user_privileges.lib.php @@ -52,18 +52,20 @@ function PMA_analyseShowGrant($rs_usr, &$is_create_db_priv, &$db_to_create, &$is $dbname_to_test = $show_grants_dbname; } - if ( (ereg($re0 . '%|_', $show_grants_dbname) - && !ereg('\\\\%|\\\\_', $show_grants_dbname)) - // does this db exist? - || (!PMA_DBI_try_query('USE ' . ereg_replace($re1 .'(%|_)', '\\1\\3', $dbname_to_test), null, PMA_DBI_QUERY_STORE) && substr(PMA_DBI_getError(), 1, 4) != 1044) - ) { - $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname)); - $db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create); - $is_create_db_priv = true; - - // TODO: collect $db_to_create into an array, to display a drop-down - // in the "Create new database" dialog - // + if ((ereg($re0 . '%|_', $show_grants_dbname) + && !ereg('\\\\%|\\\\_', $show_grants_dbname)) + // does this db exist? + || (!PMA_DBI_try_query('USE ' . ereg_replace($re1 .'(%|_)', '\\1\\3', $dbname_to_test), null, PMA_DBI_QUERY_STORE) + && substr(PMA_DBI_getError(), 1, 4) != 1044) + ) { + $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname)); + $db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create); + $is_create_db_priv = true; + + /** + * @todo collect $db_to_create into an array, to display a + * drop-down in the "Create new database" dialog + */ // we don't break, we want all possible databases //break; } // end if diff --git a/libraries/common.lib.php b/libraries/common.lib.php index d045bbb297..efc7c98375 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -800,9 +800,11 @@ if (!defined('PMA_MINIMUM_COMMON')) { // get the duplicate entry // get table name - // TODO: what would be the best delimiter, while avoiding - // special characters that can become high-ascii after editing, - // depending upon which editor is used by the developer? + /** + * @todo what would be the best delimiter, while avoiding special + * characters that can become high-ascii after editing, depending + * upon which editor is used by the developer? + */ $error_table = array(); if (preg_match('@ALTER\s*TABLE\s*\`([^\`]+)\`@iu', $the_query, $error_table)) { $error_table = $error_table[1]; @@ -1121,7 +1123,9 @@ if (!defined('PMA_MINIMUM_COMMON')) { if (is_string($a_string)) { $a_string = htmlspecialchars($a_string); $a_string = PMA_escapeJsString($a_string); - // TODO: what is this good for? + /** + * @todo what is this good for? + */ $a_string = str_replace('#', '\\#', $a_string); } @@ -1325,8 +1329,10 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm // Only append it on SELECTs. - // FIXME: what would be the best to do when someone - // hits Refresh: use the current LIMITs ? + /** + * @todo what would be the best to do when someone hits Refresh: + * use the current LIMITs ? + */ if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) { @@ -2308,7 +2314,7 @@ window.parent.updateTableTitle('<?php echo $uni_tbl; ?>', '<?php echo PMA_jsForm } // end function /** - * @TODO add documentation + * @todo add documentation */ function PMA_userDir($dir) { @@ -2521,17 +2527,20 @@ if (empty($__redirect) && !defined('PMA_NO_VARIABLES_IMPORT')) { */ /** - * @global array $GLOBALS['PMA_errors'] holds errors + * holds errors + * @global array $GLOBALS['PMA_errors'] */ $GLOBALS['PMA_errors'] = array(); /** - * @global array $GLOBALS['url_params'] holds params to be passed to next page + * holds params to be passed to next page + * @global array $GLOBALS['url_params'] */ $GLOBALS['url_params'] = array(); /** - * @global array $goto_whitelist the whitelist for $GLOBALS['goto'] + * the whitelist for $GLOBALS['goto'] + * @global array $goto_whitelist */ $goto_whitelist = array( //'browse_foreigners.php', @@ -2605,7 +2614,8 @@ if (! PMA_checkPageValidity($__redirect, $goto_whitelist)) { } /** - * @global string $GLOBALS['goto'] holds page that should be displayed + * holds page that should be displayed + * @global string $GLOBALS['goto'] */ // Security fix: disallow accessing serious server files via "?goto=" if (PMA_checkPageValidity($_REQUEST['goto'], $goto_whitelist)) { @@ -2617,7 +2627,8 @@ if (PMA_checkPageValidity($_REQUEST['goto'], $goto_whitelist)) { } /** - * @global string $GLOBALS['back'] returning page + * returning page + * @global string $GLOBALS['back'] */ if (PMA_checkPageValidity($_REQUEST['back'], $goto_whitelist)) { $GLOBALS['back'] = $_REQUEST['back']; @@ -2633,7 +2644,7 @@ if (PMA_checkPageValidity($_REQUEST['back'], $goto_whitelist)) { * could acces this variables before we reach this point * f.e. PMA_Config: fontsize * - * @todo: variables should be handled by their respective owners (objects) + * @todo variables should be handled by their respective owners (objects) * f.e. lang, server, convcharset, collation_connection in PMA_Config */ if (! isset($_REQUEST['token']) || $_SESSION['PMA_token'] != $_REQUEST['token']) { @@ -2662,14 +2673,15 @@ if (! isset($_REQUEST['token']) || $_SESSION['PMA_token'] != $_REQUEST['token']) /** * @global string $convcharset - * @see also select_lang.lib.php + * @see select_lang.lib.php */ if (isset($_REQUEST['convcharset'])) { $convcharset = strip_tags($_REQUEST['convcharset']); } /** - * @global string $GLOBALS['db'] current selected database + * current selected database + * @global string $GLOBALS['db'] */ if (isset($_REQUEST['db'])) { // can we strip tags from this? @@ -2681,7 +2693,8 @@ if (isset($_REQUEST['db'])) { } /** - * @global string $GLOBALS['table'] current selected table + * current selected table + * @global string $GLOBALS['table'] */ if (isset($_REQUEST['table'])) { // can we strip tags from this? @@ -2693,7 +2706,8 @@ if (isset($_REQUEST['table'])) { } /** - * @global string $GLOBALS['sql_query'] sql query to be executed + * sql query to be executed + * @global string $GLOBALS['sql_query'] */ if (isset($_REQUEST['sql_query'])) { $GLOBALS['sql_query'] = $_REQUEST['sql_query']; @@ -2730,7 +2744,7 @@ if (empty($_SESSION['PMA_Config'])) { } elseif (version_compare(phpversion(), '5', 'lt')) { /** - * @todo: move all __wakeup() functionality into session.inc.php + * @todo move all __wakeup() functionality into session.inc.php */ $_SESSION['PMA_Config']->__wakeup(); } @@ -2850,7 +2864,7 @@ if (! isset($_SESSION['PMA_Theme_Manager'])) { $_SESSION['PMA_Theme_Manager'] = new PMA_Theme_Manager; } else { /** - * @todo: move all __wakeup() functionality into session.inc.php + * @todo move all __wakeup() functionality into session.inc.php */ $_SESSION['PMA_Theme_Manager']->checkConfig(); } @@ -2866,7 +2880,7 @@ if (isset($_REQUEST['server']) && !isset($_REQUEST['set_theme'])) { unset($tmp); } /** - * @todo: move into PMA_Theme_Manager::__wakeup() + * @todo move into PMA_Theme_Manager::__wakeup() */ if (isset($_REQUEST['set_theme'])) { // if user selected a theme @@ -2885,7 +2899,9 @@ $GLOBALS['pmaThemeImage'] = $_SESSION['PMA_Theme']->getImgPath(); */ if (@file_exists($_SESSION['PMA_Theme']->getLayoutFile())) { include $_SESSION['PMA_Theme']->getLayoutFile(); - // @todo remove if all themes are update use Navi instead of Left as frame name + /** + * @todo remove if all themes are update use Navi instead of Left as frame name + */ if (! isset($GLOBALS['cfg']['NaviWidth']) && isset($GLOBALS['cfg']['LeftWidth'])) { $GLOBALS['cfg']['NaviWidth'] = $GLOBALS['cfg']['LeftWidth']; @@ -3080,7 +3096,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { /** * save some settings in cookies - * @todo: should be done in PMA_Config + * @todo should be done in PMA_Config */ PMA_setCookie('pma_lang', $GLOBALS['lang']); PMA_setCookie('pma_charset', $GLOBALS['convcharset']); diff --git a/libraries/config.default.php b/libraries/config.default.php index 4ba3f1bed9..87337e6b8b 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -535,8 +535,9 @@ $cfg['NaturalOrder'] = TRUE; // Sort table and database in natura //----------------------------------------------------------------------------- // custom-setup by mkkeck: 2004-05-04 // some specials for new icons and scrollings -// FIXME: -// 2004-05-08 rabus: We need to rearrange these variables. +/** + * @todo 2004-05-08 rabus: We need to rearrange these variables. + */ // Window title settings $cfg['TitleTable'] = '@HTTP_HOST@ / @VSERVER@ / @DATABASE@ / @TABLE@ | @PHPMYADMIN@'; diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index 4c25234133..4f81d932dd 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -38,8 +38,10 @@ if ( ! PMA_DBI_checkAndLoadMysqlExtension( $GLOBALS['cfg']['Server']['extension' // if it fails try alternative extension ... // and display an error ... - // TODO 2.7.1: add different messages for alternativ extension - // and complete fail (no alternativ extension too) + /** + * @todo 2.7.1: add different messages for alternativ extension + * and complete fail (no alternativ extension too) + */ $GLOBALS['PMA_errors'][] = sprintf( PMA_sanitize( $GLOBALS['strCantLoad'] ), $GLOBALS['cfg']['Server']['extension'] ) @@ -165,8 +167,9 @@ function PMA_DBI_convert_message( $message ) { } } } else { - // lang not found, try all - // what TODO ? + /** + * @todo lang not found, try all, what TODO ? + */ } return $message; @@ -334,8 +337,9 @@ function PMA_DBI_get_tables_full($database, $table = false, if ( strtoupper( $each_tables[$table_name]['Comment'] ) === 'VIEW' ) { $each_tables[$table_name]['TABLE_TYPE'] = 'VIEW'; } else { - // TODO difference between 'TEMPORARY' and 'BASE TABLE' - // but how to detect? + /** + * @todo difference between 'TEMPORARY' and 'BASE TABLE' but how to detect? + */ $each_tables[$table_name]['TABLE_TYPE'] = 'BASE TABLE'; } } @@ -650,9 +654,13 @@ function PMA_DBI_get_columns_full($database = null, $table = null, $columns[$column_name]['DATA_TYPE'] = substr($columns[$column_name]['COLUMN_TYPE'], 0, strpos($columns[$column_name]['COLUMN_TYPE'], '(')); - // @TODO guess CHARACTER_MAXIMUM_LENGTH from COLUMN_TYPE + /** + * @todo guess CHARACTER_MAXIMUM_LENGTH from COLUMN_TYPE + */ $columns[$column_name]['CHARACTER_MAXIMUM_LENGTH'] = null; - // @TODO guess CHARACTER_OCTET_LENGTH from CHARACTER_MAXIMUM_LENGTH + /** + * @todo guess CHARACTER_OCTET_LENGTH from CHARACTER_MAXIMUM_LENGTH + */ $columns[$column_name]['CHARACTER_OCTET_LENGTH'] = null; $columns[$column_name]['NUMERIC_PRECISION'] = null; $columns[$column_name]['NUMERIC_SCALE'] = null; @@ -673,7 +681,7 @@ function PMA_DBI_get_columns_full($database = null, $table = null, } /** - * @TODO should only return columns names, for more info use PMA_DBI_get_columns_full() + * @todo should only return columns names, for more info use PMA_DBI_get_columns_full() * * @deprecated by PMA_DBI_get_columns() or PMA_DBI_get_columns_full() * @param string $database name of database diff --git a/libraries/db_table_exists.lib.php b/libraries/db_table_exists.lib.php index 75ef0d5071..f2814883f9 100644 --- a/libraries/db_table_exists.lib.php +++ b/libraries/db_table_exists.lib.php @@ -47,7 +47,9 @@ if (empty($is_table) && !defined('PMA_SUBMIT_MULT')) { // (as it can happen just in case temporary table, it should be // fast): - // @todo should this check really only happen if IS_TRANSFORMATION_WRAPPER? + /** + * @todo should this check really only happen if IS_TRANSFORMATION_WRAPPER? + */ $_result = PMA_DBI_try_query( 'SELECT COUNT(*) FROM `' . PMA_sqlAddslashes($table, true) . '`;', null, PMA_DBI_QUERY_STORE); diff --git a/libraries/dbi/mysql.dbi.lib.php b/libraries/dbi/mysql.dbi.lib.php index 79e427fc3c..49e727afe7 100644 --- a/libraries/dbi/mysql.dbi.lib.php +++ b/libraries/dbi/mysql.dbi.lib.php @@ -342,7 +342,7 @@ function PMA_DBI_affected_rows($link = null) } /** - * @TODO add missing keys like in from mysqli_query (orgname, orgtable, flags, decimals) + * @todo add missing keys like in from mysqli_query (orgname, orgtable, flags, decimals) */ function PMA_DBI_get_fields_meta($result) { $fields = array(); diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index 5f17bcae02..be14d381a7 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -171,7 +171,9 @@ function PMA_DBI_try_query($query, $link = null, $options = 0) $result = mysqli_query($link, $query, $method); if (mysqli_warning_count($link)) { - // TODO: check $method ? + /** + * @todo check $method ? + */ $warning_result = mysqli_query($link, 'SHOW WARNINGS'); if ($warning_result) { $warning_row = mysqli_fetch_row($warning_result); @@ -520,7 +522,7 @@ function PMA_DBI_affected_rows($link = null) /** * returns metainfo for fields in $result * - * @TODO preserve orignal flags value + * @todo preserve orignal flags value * @uses PMA_DBI_field_flags() * @uses MYSQLI_TYPE_* * @uses MYSQLI_MULTIPLE_KEY_FLAG diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index d1f8288778..79434e9187 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -104,7 +104,10 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total) } // 2.2 Statement is a "SHOW..." elseif ($GLOBALS['is_show']) { - // 2.2.1 TODO : defines edit/delete links depending on show statement + /** + * 2.2.1 + * @todo defines edit/delete links depending on show statement + */ $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which); if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) { $do_display['edit_lnk'] = 'nn'; // no edit link @@ -138,8 +141,9 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total) && ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) { $do_display['edit_lnk'] = 'nn'; // don't display links $do_display['del_lnk'] = 'nn'; - // TODO: May be problematic with same fields names in - // two joined table. + /** + * @todo May be problematic with same fields names in two joined table. + */ // $do_display['sort_lnk'] = (string) '0'; $do_display['ins_row'] = (string) '0'; if ($do_display['text_btn'] == '1') { @@ -219,8 +223,10 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query) global $is_innodb; global $showtable; - // FIXME: move this to a central place - // FIXME: for other future table types + /** + * @todo move this to a central place + * @todo for other future table types + */ $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB'); ?> @@ -479,7 +485,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause'])); - // Get rid of ASC|DESC (TODO: analyzer) + /** + * Get rid of ASC|DESC + * @todo analyzer + */ preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches); $sort_expression_nodir = isset($matches[1]) ? trim($matches[1]) : $sort_expression; diff --git a/libraries/export/pdf.php b/libraries/export/pdf.php index 1846370a12..621dcec5ac 100644 --- a/libraries/export/pdf.php +++ b/libraries/export/pdf.php @@ -217,8 +217,10 @@ class PMA_PDF extends PMA_FPDF $this->$key = $val ; } - // Pass 1 for column widths - // TODO: force here a LIMIT to speed up pass 1 ? + /** + * Pass 1 for column widths + * @todo force here a LIMIT to speed up pass 1 ? + */ $this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED); $this->numFields = PMA_DBI_num_fields($this->results); $this->fields = PMA_DBI_get_fields_meta($this->results); @@ -248,8 +250,10 @@ class PMA_PDF extends PMA_FPDF case 'tinyblob': case 'mediumblob': case 'longblob': - //TODO: do not deactivate completely the display - // but show the field's name and [BLOB] + /** + * @todo do not deactivate completely the display + * but show the field's name and [BLOB] + */ if (stristr($this->fields[$i]->flags, 'BINARY')) { $this->display_column[$i] = false; unset($this->colTitles[$i]); @@ -263,7 +267,7 @@ class PMA_PDF extends PMA_FPDF // loop through the data, any column whose contents is bigger // than the col size is resized - // TODO: force here a LIMIT to avoid reading all rows + // TODO: force here a LIMIT to avoid reading all rows while ($row = PMA_DBI_fetch_row($this->results)) { foreach ($colFits as $key => $val) { $stringWidth = $this->getstringwidth($row[$key]) + 6 ; @@ -396,6 +400,7 @@ function PMA_exportDBCreate($db) /** * Outputs the content of a table in PDF format * + * @todo user-defined page orientation, paper size * @param string the database name * @param string the table name * @param string the end of line sequence @@ -411,7 +416,6 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) global $what; global $pdf_report_title; - // TODO: user-defined page orientation, paper size $pdf = new PMA_PDF('L', 'pt', 'A3'); $pdf->AddFont('FreeSans', '', 'FreeSans.php'); diff --git a/libraries/export/xls.php b/libraries/export/xls.php index 7e91c20eaf..07f47306bb 100644 --- a/libraries/export/xls.php +++ b/libraries/export/xls.php @@ -177,7 +177,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) if (!isset($row[$j]) || is_null($row[$j])) { $worksheet->write($col, $j, $GLOBALS['xls_null']); } elseif ($row[$j] == '0' || $row[$j] != '') { - // FIXME: we should somehow handle character set here! + /** + * @todo we should somehow handle character set here! + */ $worksheet->write($col, $j, $row[$j]); } else { $worksheet->write($col, $j, ''); diff --git a/libraries/import.lib.php b/libraries/import.lib.php index bf5414f387..5298344474 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -252,10 +252,13 @@ function PMA_importGetNextChunk($size = 32768) if ($charset_conversion) { return PMA_convert_string($charset_of_file, $charset, $result); } else { - // Skip possible byte order marks (I do not think we need more - // charsets, but feel free to add more, you can use wikipedia for - // reference: <http://en.wikipedia.org/wiki/Byte_Order_Mark>) - // @TODO: BOM could be used for charset autodetection + /** + * Skip possible byte order marks (I do not think we need more + * charsets, but feel free to add more, you can use wikipedia for + * reference: <http://en.wikipedia.org/wiki/Byte_Order_Mark>) + * + * @todo BOM could be used for charset autodetection + */ if ($offset == $size) { // UTF-8 if (strncmp($result, "\xEF\xBB\xBF", 3) == 0) { diff --git a/libraries/import/csv.php b/libraries/import/csv.php index 243dc1b4ff..010c8bd770 100644 --- a/libraries/import/csv.php +++ b/libraries/import/csv.php @@ -44,7 +44,7 @@ if ($plugin_param == 'table') { $message = sprintf($strInvalidCSVParameter, $strFieldsEscapedBy); $show_error_header = TRUE; $error = TRUE; - } elseif (strlen($csv_new_line) != 1 && $csv_new_line != 'auto') { + } elseif (strlen($csv_new_line) != 1 && $csv_new_line != 'auto') { $message = sprintf($strInvalidCSVParameter, $strLinesTerminatedBy); $show_error_header = TRUE; $error = TRUE; @@ -60,9 +60,9 @@ if ($plugin_param == 'table') { } } $sql_template .= ' INTO ' . PMA_backquote($table); - + $tmp_fields = PMA_DBI_get_fields($db, $table); - + if (empty($csv_columns)) { $fields = $tmp_fields; } else { @@ -151,7 +151,7 @@ if ($plugin_param == 'table') { continue; } - // Grab one field + // Grab one field $fallbacki = $i; if ($ch == $csv_enclosed) { $need_end = TRUE; @@ -246,7 +246,7 @@ if ($plugin_param == 'table') { break; } } - + $first = TRUE; $sql = $sql_template; foreach ($values as $key => $val) { @@ -258,7 +258,9 @@ if ($plugin_param == 'table') { } $sql .= ')'; - // FIXME: maybe we could add original line to verbose SQL in comment + /** + * @todo maybe we could add original line to verbose SQL in comment + */ PMA_importRunQuery($sql, $sql); $line++; $csv_finish = FALSE; @@ -274,7 +276,7 @@ if ($plugin_param == 'table') { // Commit any possible data in buffers PMA_importRunQuery(); - + if (count($values) != 0 && !$error) { $message = sprintf($strInvalidCSVFormat, $line); $show_error_header = TRUE; diff --git a/libraries/parse_analyze.lib.php b/libraries/parse_analyze.lib.php index 5d680104b7..c862a69b17 100644 --- a/libraries/parse_analyze.lib.php +++ b/libraries/parse_analyze.lib.php @@ -25,11 +25,12 @@ $is_select = isset($analyzed_sql[0]['queryflags']['select_from']); // db and table name may be enclosed with backquotes, db is optionnal, // query may contain aliases. -// (TODO: if there are more than one table name in the Select: -// - do not extract the first table name -// - do not show a table name in the page header -// - do not display the sub-pages links) - +/** + * @todo if there are more than one table name in the Select: + * - do not extract the first table name + * - do not show a table name in the page header + * - do not display the sub-pages links) + */ if ($is_select) { $prev_db = $db; if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) { diff --git a/libraries/select_server.lib.php b/libraries/select_server.lib.php index 0be2de6f54..3b94c4601f 100644 --- a/libraries/select_server.lib.php +++ b/libraries/select_server.lib.php @@ -69,7 +69,9 @@ function PMA_select_server($not_only_options, $ommit_fieldset) // value, displaying such informations may not be a so good // idea if (!empty($server['only_db'])) { - // TODO FIXME this can become a really big/long/wide selectbox ... + /** + * @todo this can become a really big/long/wide selectbox ... + */ $label .= ' - ' . (is_array($server['only_db']) ? implode(', ', $server['only_db']) : $server['only_db']); } if (!empty($server['user']) && $server['auth_type'] == 'config') { diff --git a/libraries/session.inc.php b/libraries/session.inc.php index fee6c8b1a9..3b37c6a4ad 100644 --- a/libraries/session.inc.php +++ b/libraries/session.inc.php @@ -4,8 +4,8 @@ /** * session handling * - * @TODO add failover or warn if sessions are not configured properly - * @TODO add an option to use mm-module for session handler + * @todo add failover or warn if sessions are not configured properly + * @todo add an option to use mm-module for session handler * @see http://www.php.net/session * @uses session_name() * @uses session_start() diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index ca98e2baf8..b5e0d07f89 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -381,10 +381,11 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { if (PMA_STR_isSqlIdentifier($c, FALSE) || ($c == '@') || ($c == '.' && PMA_STR_isDigit(PMA_substr($sql, $count2 + 1, 1)))) { $count2 ++; - //TODO: a @ can also be present in expressions like - // FROM 'user'@'%' - // or TO 'user'@'%' - // in this case, the @ is wrongly marked as alpha_variable + /** + * @todo a @ can also be present in expressions like + * FROM 'user'@'%' or TO 'user'@'%' + * in this case, the @ is wrongly marked as alpha_variable + */ $is_sql_variable = ($c == '@'); $is_digit = (!$is_sql_variable) && PMA_STR_isDigit($c); @@ -523,9 +524,11 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { } elseif (($last == '-') || ($last == '+') || ($last == '!')) { $count2--; $punct_data = PMA_substr($sql, $count1, $count2 - $count1); - // TODO: for negation operator, split in 2 tokens ? - // "select x&~1 from t" - // becomes "select x & ~ 1 from t" ? + /** + * @todo for negation operator, split in 2 tokens ? + * "select x&~1 from t" + * becomes "select x & ~ 1 from t" ? + */ } elseif ($last != '~') { $debugstr = $GLOBALS['strSQPBugUnknownPunctuation'] . ' @ ' . ($count1+1) . "\n" @@ -593,17 +596,22 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { $t_suffix = '_identifier'; } elseif (($t_next == 'punct_bracket_open_round') && PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_function_name, $PMA_SQPdata_function_name_cnt)) { - // FIXME-2005-10-16: in the case of a CREATE TABLE containing a TIMESTAMP, - // since TIMESTAMP() is also a function, it's found here and - // the token is wrongly marked as alpha_functionName. But we - // compensate for this when analysing for timestamp_not_null - // later in this script. + /** + * @todo 2005-10-16: in the case of a CREATE TABLE containing + * a TIMESTAMP, since TIMESTAMP() is also a function, it's + * found here and the token is wrongly marked as alpha_functionName. + * But we compensate for this when analysing for timestamp_not_null + * later in this script. + */ $t_suffix = '_functionName'; } elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_type, $PMA_SQPdata_column_type_cnt)) { $t_suffix = '_columnType'; - // Temporary fix for BUG #621357 - //TODO FIX PROPERLY NEEDS OVERHAUL OF SQL TOKENIZER + /** + * Temporary fix for BUG #621357 + * + * @todo FIX PROPERLY NEEDS OVERHAUL OF SQL TOKENIZER + */ if ($d_cur_upper == 'SET' && $t_next != 'punct_bracket_open_round') { $t_suffix = '_reservedWord'; } @@ -915,10 +923,10 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { } // end if (type == punct_queryend) } // end if ($seek_queryend) - // TODO: when we find a UNION, should we split - // in another subresult? - // Note: do not split if this is a punct_queryend for the - // first and only query + /** + * Note: do not split if this is a punct_queryend for the first and only query + * @todo when we find a UNION, should we split in another subresult? + */ if ($arr[$i]['type'] == 'punct_queryend' && ($i + 1 != $size)) { $result[] = $subresult; $subresult = $subresult_empty; @@ -980,7 +988,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { // upper once $upper_data = strtoupper($arr[$i]['data']); - //TODO: reset for each query? + /** + * @todo reset for each query? + */ if ($upper_data == 'SELECT') { $seen_from = FALSE; @@ -1011,14 +1021,13 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { switch ($arr[$i]['type']) { case 'alpha_identifier': case 'alpha_reservedWord': - // this is not a real reservedWord, because - // it's not present in the list of forbidden words, - // for example "storage" which can be used as - // an identifier - // - // TODO: avoid the pretty printing in color - // in this case - + /** + * this is not a real reservedWord, because it's not + * present in the list of forbidden words, for example + * "storage" which can be used as an identifier + * + * @todo avoid the pretty printing in color in this case + */ $identifier = $arr[$i]['data']; break; @@ -1067,7 +1076,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { continue; } // end if (punct_qualifier) - // TODO: check if 3 identifiers following one another -> error + /** + * @todo check if 3 identifiers following one another -> error + */ // s a v e a s e l e c t e x p r // finding a list separator or FROM @@ -1122,7 +1133,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { } // end if ($size_chain > 2) unset($chain); - // TODO: explain this: + /** + * @todo explain this: + */ if (($arr[$i]['type'] == 'alpha_reservedWord') && ($upper_data != 'FROM')) { $previous_was_identifier = TRUE; @@ -1137,9 +1150,11 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { // maybe we just saw the end of table refs // but the last table ref has to be saved - // or we are at the last token (TODO: there could be another - // query after this one) + // or we are at the last token // or we just got a reserved word + /** + * @todo there could be another query after this one + */ if (isset($chain) && $seen_from && $save_table_ref && ($arr[$i]['type'] == 'punct_listsep' @@ -1204,62 +1219,65 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { } // end if (set the true names) - // e n d i n g l o o p #1 - // set the $previous_was_identifier to FALSE if the current - // token is not an identifier - if (($arr[$i]['type'] != 'alpha_identifier') - && ($arr[$i]['type'] != 'quote_double') - && ($arr[$i]['type'] != 'quote_single') - && ($arr[$i]['type'] != 'quote_backtick')) { - $previous_was_identifier = FALSE; - } // end if - - // however, if we are on AS, we must keep the $previous_was_identifier - if (($arr[$i]['type'] == 'alpha_reservedWord') - && ($upper_data == 'AS')) { - $previous_was_identifier = TRUE; - } - - if (($arr[$i]['type'] == 'alpha_reservedWord') - && ($upper_data =='ON' || $upper_data =='USING')) { - $save_table_ref = FALSE; - } // end if (data == ON) - - if (($arr[$i]['type'] == 'alpha_reservedWord') - && ($upper_data =='JOIN' || $upper_data =='FROM')) { - $save_table_ref = TRUE; - } // end if (data == JOIN) - - // no need to check the end of table ref if we already did - // TODO: maybe add "&& $seen_from" - if (!$seen_end_of_table_ref) { - // if this is the last token, it implies that we have - // seen the end of table references - // Check for the end of table references - // - // Note: if we are analyzing a GROUP_CONCAT clause, - // we might find a word that seems to indicate that - // we have found the end of table refs (like ORDER) - // but it's a modifier of the GROUP_CONCAT so - // it's not the real end of table refs - if (($i == $size-1) + // e n d i n g l o o p #1 + // set the $previous_was_identifier to FALSE if the current + // token is not an identifier + if (($arr[$i]['type'] != 'alpha_identifier') + && ($arr[$i]['type'] != 'quote_double') + && ($arr[$i]['type'] != 'quote_single') + && ($arr[$i]['type'] != 'quote_backtick')) { + $previous_was_identifier = FALSE; + } // end if + + // however, if we are on AS, we must keep the $previous_was_identifier + if (($arr[$i]['type'] == 'alpha_reservedWord') + && ($upper_data == 'AS')) { + $previous_was_identifier = TRUE; + } + + if (($arr[$i]['type'] == 'alpha_reservedWord') + && ($upper_data =='ON' || $upper_data =='USING')) { + $save_table_ref = FALSE; + } // end if (data == ON) + + if (($arr[$i]['type'] == 'alpha_reservedWord') + && ($upper_data =='JOIN' || $upper_data =='FROM')) { + $save_table_ref = TRUE; + } // end if (data == JOIN) + + /** + * no need to check the end of table ref if we already did + * + * @todo maybe add "&& $seen_from" + */ + if (!$seen_end_of_table_ref) { + // if this is the last token, it implies that we have + // seen the end of table references + // Check for the end of table references + // + // Note: if we are analyzing a GROUP_CONCAT clause, + // we might find a word that seems to indicate that + // we have found the end of table refs (like ORDER) + // but it's a modifier of the GROUP_CONCAT so + // it's not the real end of table refs + if (($i == $size-1) || ($arr[$i]['type'] == 'alpha_reservedWord' && !$in_group_concat && PMA_STR_binarySearchInArr($upper_data, $words_ending_table_ref, $words_ending_table_ref_cnt))) { - $seen_end_of_table_ref = TRUE; - // to be able to save the last table ref, but do not - // set it true if we found a word like "ON" that has - // already set it to false - if (isset($save_table_ref) && $save_table_ref != FALSE) { - $save_table_ref = TRUE; - } //end if - - } // end if (check for end of table ref) - } //end if (!$seen_end_of_table_ref) - - if ($seen_end_of_table_ref) { - $save_table_ref = FALSE; - } // end if + $seen_end_of_table_ref = TRUE; + // to be able to save the last table ref, but do not + // set it true if we found a word like "ON" that has + // already set it to false + if (isset($save_table_ref) && $save_table_ref != FALSE) { + $save_table_ref = TRUE; + } //end if + + } // end if (check for end of table ref) + } //end if (!$seen_end_of_table_ref) + + if ($seen_end_of_table_ref) { + $save_table_ref = FALSE; + } // end if } // end for $i (loop #1) @@ -1320,237 +1338,237 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { for ($i = 0; $i < $size; $i++) { //DEBUG echo "trace loop2 <b>" . $arr[$i]['data'] . "</b> (" . $arr[$i]['type'] . ")<br />"; - // need_confirm - // - // check for reserved words that will have to generate - // a confirmation request later in sql.php - // the cases are: - // DROP TABLE - // DROP DATABASE - // ALTER TABLE... DROP - // DELETE FROM... - // - // this code is not used for confirmations coming from functions.js - - // TODO: check for punct_queryend - - - // TODO: verify C-style comments? - if ($arr[$i]['type'] == 'comment_ansi') { - $collect_section_before_limit = FALSE; - } - - if ($arr[$i]['type'] == 'alpha_reservedWord') { - $upper_data = strtoupper($arr[$i]['data']); - if (!$seen_reserved_word) { - $first_reserved_word = $upper_data; - $subresult['querytype'] = $upper_data; - $seen_reserved_word = TRUE; - - // if the first reserved word is DROP or DELETE, - // we know this is a query that needs to be confirmed - if ($first_reserved_word=='DROP' - || $first_reserved_word == 'DELETE' - || $first_reserved_word == 'TRUNCATE') { - $subresult['queryflags']['need_confirm'] = 1; - } - - if ($first_reserved_word=='SELECT'){ - $position_of_first_select = $i; - } - - } else { - if ($upper_data=='DROP' && $first_reserved_word=='ALTER') { - $subresult['queryflags']['need_confirm'] = 1; - } - } + // need_confirm + // + // check for reserved words that will have to generate + // a confirmation request later in sql.php + // the cases are: + // DROP TABLE + // DROP DATABASE + // ALTER TABLE... DROP + // DELETE FROM... + // + // this code is not used for confirmations coming from functions.js + + /** + * @todo check for punct_queryend + * @todo verify C-style comments? + */ + if ($arr[$i]['type'] == 'comment_ansi') { + $collect_section_before_limit = FALSE; + } - if ($upper_data == 'PROCEDURE') { - $collect_section_before_limit = FALSE; - } - // TODO: set also to FALSE if we find - // FOR UPDATE - // LOCK IN SHARE MODE + if ($arr[$i]['type'] == 'alpha_reservedWord') { + $upper_data = strtoupper($arr[$i]['data']); + if (!$seen_reserved_word) { + $first_reserved_word = $upper_data; + $subresult['querytype'] = $upper_data; + $seen_reserved_word = TRUE; + + // if the first reserved word is DROP or DELETE, + // we know this is a query that needs to be confirmed + if ($first_reserved_word=='DROP' + || $first_reserved_word == 'DELETE' + || $first_reserved_word == 'TRUNCATE') { + $subresult['queryflags']['need_confirm'] = 1; + } - if ($upper_data == 'SELECT') { - $in_select_expr = TRUE; - $select_expr_clause = ''; - } - if ($upper_data == 'DISTINCT' && !$in_group_concat) { - $subresult['queryflags']['distinct'] = 1; - } + if ($first_reserved_word=='SELECT'){ + $position_of_first_select = $i; + } - if ($upper_data == 'UNION') { - $subresult['queryflags']['union'] = 1; - } + } else { + if ($upper_data=='DROP' && $first_reserved_word=='ALTER') { + $subresult['queryflags']['need_confirm'] = 1; + } + } - if ($upper_data == 'JOIN') { - $subresult['queryflags']['join'] = 1; - } + if ($upper_data == 'PROCEDURE') { + $collect_section_before_limit = FALSE; + } + /** + * @todo set also to FALSE if we find FOR UPDATE or LOCK IN SHARE MODE + */ + if ($upper_data == 'SELECT') { + $in_select_expr = TRUE; + $select_expr_clause = ''; + } + if ($upper_data == 'DISTINCT' && !$in_group_concat) { + $subresult['queryflags']['distinct'] = 1; + } - if ($upper_data == 'OFFSET') { - $subresult['queryflags']['offset'] = 1; - } + if ($upper_data == 'UNION') { + $subresult['queryflags']['union'] = 1; + } - // if this is a real SELECT...FROM - if ($upper_data == 'FROM' && isset($subresult['queryflags']['select_from']) && $subresult['queryflags']['select_from'] == 1) { - $in_from = TRUE; - $from_clause = ''; - $in_select_expr = FALSE; - } + if ($upper_data == 'JOIN') { + $subresult['queryflags']['join'] = 1; + } + if ($upper_data == 'OFFSET') { + $subresult['queryflags']['offset'] = 1; + } - // (we could have less resetting of variables to FALSE - // if we trust that the query respects the standard - // MySQL order for clauses) - - // we use $seen_group and $seen_order because we are looking - // for the BY - if ($upper_data == 'GROUP') { - $seen_group = TRUE; - $seen_order = FALSE; - $in_having = FALSE; - $in_order_by = FALSE; - $in_where = FALSE; - $in_select_expr = FALSE; - $in_from = FALSE; - } - if ($upper_data == 'ORDER' && !$in_group_concat) { - $seen_order = TRUE; - $seen_group = FALSE; - $in_having = FALSE; - $in_group_by = FALSE; - $in_where = FALSE; - $in_select_expr = FALSE; - $in_from = FALSE; - } - if ($upper_data == 'HAVING') { - $in_having = TRUE; - $having_clause = ''; - $seen_group = FALSE; - $seen_order = FALSE; - $in_group_by = FALSE; - $in_order_by = FALSE; - $in_where = FALSE; - $in_select_expr = FALSE; - $in_from = FALSE; - } + // if this is a real SELECT...FROM + if ($upper_data == 'FROM' && isset($subresult['queryflags']['select_from']) && $subresult['queryflags']['select_from'] == 1) { + $in_from = TRUE; + $from_clause = ''; + $in_select_expr = FALSE; + } - if ($upper_data == 'WHERE') { - $in_where = TRUE; - $where_clause = ''; - $where_clause_identifiers = array(); - $seen_group = FALSE; - $seen_order = FALSE; - $in_group_by = FALSE; - $in_order_by = FALSE; - $in_having = FALSE; - $in_select_expr = FALSE; - $in_from = FALSE; - } - if ($upper_data == 'BY') { - if ($seen_group) { - $in_group_by = TRUE; - $group_by_clause = ''; - } - if ($seen_order) { - $in_order_by = TRUE; - $order_by_clause = ''; - } - } + // (we could have less resetting of variables to FALSE + // if we trust that the query respects the standard + // MySQL order for clauses) + + // we use $seen_group and $seen_order because we are looking + // for the BY + if ($upper_data == 'GROUP') { + $seen_group = TRUE; + $seen_order = FALSE; + $in_having = FALSE; + $in_order_by = FALSE; + $in_where = FALSE; + $in_select_expr = FALSE; + $in_from = FALSE; + } + if ($upper_data == 'ORDER' && !$in_group_concat) { + $seen_order = TRUE; + $seen_group = FALSE; + $in_having = FALSE; + $in_group_by = FALSE; + $in_where = FALSE; + $in_select_expr = FALSE; + $in_from = FALSE; + } + if ($upper_data == 'HAVING') { + $in_having = TRUE; + $having_clause = ''; + $seen_group = FALSE; + $seen_order = FALSE; + $in_group_by = FALSE; + $in_order_by = FALSE; + $in_where = FALSE; + $in_select_expr = FALSE; + $in_from = FALSE; + } - // if we find one of the words that could end the clause - if (PMA_STR_binarySearchInArr($upper_data, $words_ending_clauses, $words_ending_clauses_cnt)) { + if ($upper_data == 'WHERE') { + $in_where = TRUE; + $where_clause = ''; + $where_clause_identifiers = array(); + $seen_group = FALSE; + $seen_order = FALSE; + $in_group_by = FALSE; + $in_order_by = FALSE; + $in_having = FALSE; + $in_select_expr = FALSE; + $in_from = FALSE; + } - $in_group_by = FALSE; - $in_order_by = FALSE; - $in_having = FALSE; - $in_where = FALSE; - $in_select_expr = FALSE; - $in_from = FALSE; - } + if ($upper_data == 'BY') { + if ($seen_group) { + $in_group_by = TRUE; + $group_by_clause = ''; + } + if ($seen_order) { + $in_order_by = TRUE; + $order_by_clause = ''; + } + } - } // endif (reservedWord) + // if we find one of the words that could end the clause + if (PMA_STR_binarySearchInArr($upper_data, $words_ending_clauses, $words_ending_clauses_cnt)) { + $in_group_by = FALSE; + $in_order_by = FALSE; + $in_having = FALSE; + $in_where = FALSE; + $in_select_expr = FALSE; + $in_from = FALSE; + } - // do not add a blank after a function name - // TODO: can we combine loop 2 and loop 1? - // some code is repeated here... + } // endif (reservedWord) - $sep=' '; - if ($arr[$i]['type'] == 'alpha_functionName') { - $sep=''; - $upper_data = strtoupper($arr[$i]['data']); - if ($upper_data =='GROUP_CONCAT') { - $in_group_concat = TRUE; - $number_of_brackets_in_group_concat = 0; - } - } - if ($arr[$i]['type'] == 'punct_bracket_open_round') { - if ($in_group_concat) { - $number_of_brackets_in_group_concat++; - } - } - if ($arr[$i]['type'] == 'punct_bracket_close_round') { - if ($in_group_concat) { - $number_of_brackets_in_group_concat--; - if ($number_of_brackets_in_group_concat == 0) { - $in_group_concat = FALSE; - } - } - } - - if ($in_select_expr && $upper_data != 'SELECT' && $upper_data != 'DISTINCT') { - $select_expr_clause .= $arr[$i]['data'] . $sep; - } - if ($in_from && $upper_data != 'FROM') { - $from_clause .= $arr[$i]['data'] . $sep; - } - if ($in_group_by && $upper_data != 'GROUP' && $upper_data != 'BY') { - $group_by_clause .= $arr[$i]['data'] . $sep; - } - if ($in_order_by && $upper_data != 'ORDER' && $upper_data != 'BY') { - // add a space only before ASC or DESC - // not around the dot between dbname and tablename - if ($arr[$i]['type'] == 'alpha_reservedWord') { - $order_by_clause .= $sep; - } - $order_by_clause .= $arr[$i]['data']; - } - if ($in_having && $upper_data != 'HAVING') { - $having_clause .= $arr[$i]['data'] . $sep; - } - if ($in_where && $upper_data != 'WHERE') { - $where_clause .= $arr[$i]['data'] . $sep; - - if (($arr[$i]['type'] == 'quote_backtick') - || ($arr[$i]['type'] == 'alpha_identifier')) { - $where_clause_identifiers[] = $arr[$i]['data']; - } - } + // do not add a blank after a function name + /** + * @todo can we combine loop 2 and loop 1? some code is repeated here... + */ + + $sep = ' '; + if ($arr[$i]['type'] == 'alpha_functionName') { + $sep=''; + $upper_data = strtoupper($arr[$i]['data']); + if ($upper_data =='GROUP_CONCAT') { + $in_group_concat = TRUE; + $number_of_brackets_in_group_concat = 0; + } + } + + if ($arr[$i]['type'] == 'punct_bracket_open_round') { + if ($in_group_concat) { + $number_of_brackets_in_group_concat++; + } + } + if ($arr[$i]['type'] == 'punct_bracket_close_round') { + if ($in_group_concat) { + $number_of_brackets_in_group_concat--; + if ($number_of_brackets_in_group_concat == 0) { + $in_group_concat = FALSE; + } + } + } - if (isset($subresult['queryflags']['select_from']) + if ($in_select_expr && $upper_data != 'SELECT' && $upper_data != 'DISTINCT') { + $select_expr_clause .= $arr[$i]['data'] . $sep; + } + if ($in_from && $upper_data != 'FROM') { + $from_clause .= $arr[$i]['data'] . $sep; + } + if ($in_group_by && $upper_data != 'GROUP' && $upper_data != 'BY') { + $group_by_clause .= $arr[$i]['data'] . $sep; + } + if ($in_order_by && $upper_data != 'ORDER' && $upper_data != 'BY') { + // add a space only before ASC or DESC + // not around the dot between dbname and tablename + if ($arr[$i]['type'] == 'alpha_reservedWord') { + $order_by_clause .= $sep; + } + $order_by_clause .= $arr[$i]['data']; + } + if ($in_having && $upper_data != 'HAVING') { + $having_clause .= $arr[$i]['data'] . $sep; + } + if ($in_where && $upper_data != 'WHERE') { + $where_clause .= $arr[$i]['data'] . $sep; + + if (($arr[$i]['type'] == 'quote_backtick') + || ($arr[$i]['type'] == 'alpha_identifier')) { + $where_clause_identifiers[] = $arr[$i]['data']; + } + } + + if (isset($subresult['queryflags']['select_from']) && $subresult['queryflags']['select_from'] == 1 && !$seen_order) { - $unsorted_query .= $arr[$i]['data']; + $unsorted_query .= $arr[$i]['data']; - if ($arr[$i]['type'] != 'punct_bracket_open_round' - && $arr[$i]['type'] != 'punct_bracket_close_round' - && $arr[$i]['type'] != 'punct') { - $unsorted_query .= $sep; - } - } + if ($arr[$i]['type'] != 'punct_bracket_open_round' + && $arr[$i]['type'] != 'punct_bracket_close_round' + && $arr[$i]['type'] != 'punct') { + $unsorted_query .= $sep; + } + } - // clear $upper_data for next iteration - $upper_data=''; + // clear $upper_data for next iteration + $upper_data=''; - if ($collect_section_before_limit && $arr[$i]['type'] != 'punct_queryend') { - $section_before_limit .= $arr[$i]['data'] . $sep; - } else { - $section_after_limit .= $arr[$i]['data'] . $sep; - } + if ($collect_section_before_limit && $arr[$i]['type'] != 'punct_queryend') { + $section_before_limit .= $arr[$i]['data'] . $sep; + } else { + $section_after_limit .= $arr[$i]['data'] . $sep; + } } // end for $i (loop #2) @@ -1712,8 +1730,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { } } - // note: the "or" part here is a workaround for a bug - // (see FIXME-2005-10-16) + /** + * @see @todo 2005-10-16 note: the "or" part here is a workaround for a bug + */ if (($arr[$i]['type'] == 'alpha_columnType') || ($arr[$i]['type'] == 'alpha_functionName' && $seen_create_table)) { $upper_data = strtoupper($arr[$i]['data']); if ($seen_create_table && $in_create_table_fields && isset($current_identifier)) { @@ -1835,6 +1854,8 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { /** * Colorizes SQL queries html formatted * + * @todo check why adding a "\n" after the </span> would cause extra blanks + * to be displayed: SELECT p . person_name * @param array The SQL queries html formatted * * @return array The colorized SQL queries @@ -1851,10 +1872,6 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { $class .= 'syntax_' . $arr['type']; - //TODO: check why adding a "\n" after the </span> would cause extra - // blanks to be displayed: - // SELECT p . person_name - return '<span class="' . $class . '">' . htmlspecialchars($arr['data']) . '</span>'; } // end of the "PMA_SQP_formatHtml_colorize()" function @@ -2137,8 +2154,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { // the quote_single exception is there to // catch cases like // GRANT ... TO 'marc'@'domain.com' IDENTIFIED... - // - // TODO: fix all cases and find why this happens + /** + * @todo fix all cases and find why this happens + */ if (!$in_priv_list || $typearr[1] == 'alpha_identifier' || $typearr[1] == 'quote_single' || $typearr[1] == 'white_newline') { $before .= $space_alpha_reserved_word; @@ -2201,7 +2219,9 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { case 'digit_integer': case 'digit_float': case 'digit_hex': - //TODO: could there be other types preceding a digit? + /** + * @todo could there be other types preceding a digit? + */ if ($typearr[1] == 'alpha_reservedWord') { $after .= ' '; } @@ -2335,6 +2355,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { /** * Gets SQL queries in text format * + * @todo WRITE THIS! * @param array The SQL queries list * * @return string The SQL queries in text format @@ -2343,9 +2364,6 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { */ function PMA_SQP_formatText($arr) { - /** - * TODO WRITE THIS! - */ return PMA_SQP_formatNone($arr); } // end of the "PMA_SQP_formatText()" function } // end if: minimal common.lib needed? diff --git a/libraries/tbl_properties_table_info.inc.php b/libraries/tbl_properties_table_info.inc.php index dad94d05a0..9130d4eb48 100644 --- a/libraries/tbl_properties_table_info.inc.php +++ b/libraries/tbl_properties_table_info.inc.php @@ -7,7 +7,7 @@ require_once './libraries/Table.class.php'; /** * extracts table properties from create statement * - * @TODO this should be recoded as functions, + * @todo this should be recoded as functions, * to avoid messing with global variables */ @@ -191,7 +191,11 @@ if ($server > 0) { PMA_printListItem($strImport, 'li_import', './server_import.php?' . $common_url_query); - // Change password (TODO ? needs another message) + /** + * Change password + * + * @todo ? needs another message + */ if ($cfg['ShowChgPassword']) { PMA_printListItem($strChangePassword, 'li_change_password', './user_password.php?' . $common_url_query); diff --git a/pdf_schema.php b/pdf_schema.php index 047d47d8a9..557eda41c0 100644 --- a/pdf_schema.php +++ b/pdf_schema.php @@ -1265,7 +1265,9 @@ function PMA_RT_DOC($alltables) $comments_width = 67; } else { // this is really intended for 'letter' - // TODO: find optimal width for all formats + /** + * @todo find optimal width for all formats + */ $comments_width = 50; } $pdf->Cell($comments_width, 8, ucfirst($GLOBALS['strComments']), 1, 0, 'C'); diff --git a/server_collations.php b/server_collations.php index 66be80e86b..34a8c83377 100644 --- a/server_collations.php +++ b/server_collations.php @@ -34,10 +34,10 @@ echo '<h2>' . "\n" /** - * Checks the MySQL version + * exits if wrong MySQL version + * @todo Some nice Message :-) */ if (PMA_MYSQL_INT_VERSION < 40100) { - // TODO: Some nice Message :-) require_once('./libraries/footer.inc.php'); } diff --git a/server_privileges.php b/server_privileges.php index cdc36eb501..64e9663785 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -783,7 +783,9 @@ if (!empty($adduser_submit) || !empty($change_copy)) { $create_user_show = $create_user_real; } } - // FIXME: similar code appears twice in this script + /** + * @todo similar code appears twice in this script + */ if ((isset($Grant_priv) && $Grant_priv == 'Y') || (PMA_MYSQL_INT_VERSION >= 40002 && (isset($max_questions) || isset($max_connections) || isset($max_updates) || isset($max_user_connections)))) { $real_sql_query .= 'WITH'; $sql_query .= 'WITH'; @@ -989,7 +991,9 @@ if (!empty($update_privs)) { . ' ON ' . $db_and_table . ' TO \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\''; - // FIXME: similar code appears twice in this script + /** + * @todo similar code appears twice in this script + */ if ( ( isset($Grant_priv) && $Grant_priv == 'Y') || ( ( ! isset($dbname) || ! strlen($dbname) ) && PMA_MYSQL_INT_VERSION >= 40002 && ( isset($max_questions) || isset($max_connections) @@ -131,7 +131,7 @@ if (isset($btnDrop) || isset($navig)) { } /** - * Parse and analyze the query + * Parse and analyze the query */ require_once('./libraries/parse_analyze.lib.php'); @@ -221,501 +221,512 @@ if ($do_confirm) { <?php echo '</fieldset>' . "\n" . '</form>' . "\n"; + + /** + * Displays the footer and exit + */ + require_once './libraries/footer.inc.php'; } // end if $do_confirm /** * Executes the query and displays results */ -else { - if (!isset($sql_query)) { - $sql_query = ''; - } - // Defines some variables - // A table has to be created or renamed -> left frame should be reloaded - // TODO: use the parser/analyzer +if (!isset($sql_query)) { + $sql_query = ''; +} - if (empty($reload) - && preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) { - $reload = 1; - } - // Gets the number of rows per page - if (empty($session_max_rows)) { - $session_max_rows = $cfg['MaxRows']; - } elseif ($session_max_rows != 'all') { - $cfg['MaxRows'] = $session_max_rows; - } - // Defines the display mode (horizontal/vertical) and header "frequency" - if (empty($disp_direction)) { - $disp_direction = $cfg['DefaultDisplay']; - } - if (empty($repeat_cells)) { - $repeat_cells = $cfg['RepeatCells']; +// Defines some variables +// A table has to be created or renamed -> left frame should be reloaded +/** + * @todo use the parser/analyzer + */ + +if (empty($reload) + && preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) { + $reload = 1; +} +// Gets the number of rows per page +if (empty($session_max_rows)) { + $session_max_rows = $cfg['MaxRows']; +} elseif ($session_max_rows != 'all') { + $cfg['MaxRows'] = $session_max_rows; +} +// Defines the display mode (horizontal/vertical) and header "frequency" +if (empty($disp_direction)) { + $disp_direction = $cfg['DefaultDisplay']; +} +if (empty($repeat_cells)) { + $repeat_cells = $cfg['RepeatCells']; +} + +// SK -- Patch: $is_group added for use in calculation of total number of +// rows. +// $is_count is changed for more correct "LIMIT" clause +// appending in queries like +// "SELECT COUNT(...) FROM ... GROUP BY ..." + +/** + * @todo detect all this with the parser, to avoid problems finding + * those strings in comments or backquoted identifiers + */ + +$is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = $is_replace = false; +if ($is_select) { // see line 141 + $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query); + $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query)); + $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query)); + $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query)); + $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query)); +} elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) { + $is_explain = true; +} elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) { + $is_delete = true; + $is_affected = true; +} elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) { + $is_insert = true; + $is_affected = true; + if (preg_match('@^(REPLACE)[[:space:]]+@i', $sql_query)) { + $is_replace = true; } +} elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) { + $is_affected = true; +} elseif (preg_match('@^SHOW[[:space:]]+@i', $sql_query)) { + $is_show = true; +} elseif (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) { + $is_maint = true; +} - // SK -- Patch: $is_group added for use in calculation of total number of - // rows. - // $is_count is changed for more correct "LIMIT" clause - // appending in queries like - // "SELECT COUNT(...) FROM ... GROUP BY ..." - - // TODO: detect all this with the parser, to avoid problems finding - // those strings in comments or backquoted identifiers - - $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = $is_replace = false; - if ($is_select) { // see line 141 - $is_group = preg_match('@(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+@i', $sql_query); - $is_func = !$is_group && (preg_match('@[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(@i', $sql_query)); - $is_count = !$is_group && (preg_match('@^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)@i', $sql_query)); - $is_export = (preg_match('@[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+@i', $sql_query)); - $is_analyse = (preg_match('@[[:space:]]+PROCEDURE[[:space:]]+ANALYSE@i', $sql_query)); - } elseif (preg_match('@^EXPLAIN[[:space:]]+@i', $sql_query)) { - $is_explain = true; - } elseif (preg_match('@^DELETE[[:space:]]+@i', $sql_query)) { - $is_delete = true; - $is_affected = true; - } elseif (preg_match('@^(INSERT|LOAD[[:space:]]+DATA|REPLACE)[[:space:]]+@i', $sql_query)) { - $is_insert = true; - $is_affected = true; - if (preg_match('@^(REPLACE)[[:space:]]+@i', $sql_query)) { - $is_replace = true; +// Do append a "LIMIT" clause? +if (isset($pos) + && (!$cfg['ShowAll'] || $session_max_rows != 'all') + && !($is_count || $is_export || $is_func || $is_analyse) + && isset($analyzed_sql[0]['queryflags']['select_from']) + && !isset($analyzed_sql[0]['queryflags']['offset']) + && !preg_match('@[[:space:]]LIMIT[[:space:]0-9,-]+(;)?$@i', $sql_query)) { + $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'] . " "; + + $full_sql_query = $analyzed_sql[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit']; + /** + * @todo pretty printing of this modified query + */ + if (isset($display_query)) { + // if the analysis of the original query revealed that we found + // a section_after_limit, we now have to analyze $display_query + // to display it correctly + + if (!empty($analyzed_sql[0]['section_after_limit']) && trim($analyzed_sql[0]['section_after_limit']) != ';') { + $analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query)); + $display_query = $analyzed_display_query[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit']; } - } elseif (preg_match('@^UPDATE[[:space:]]+@i', $sql_query)) { - $is_affected = true; - } elseif (preg_match('@^SHOW[[:space:]]+@i', $sql_query)) { - $is_show = true; - } elseif (preg_match('@^(CHECK|ANALYZE|REPAIR|OPTIMIZE)[[:space:]]+TABLE[[:space:]]+@i', $sql_query)) { - $is_maint = true; } - // Do append a "LIMIT" clause? - if (isset($pos) - && (!$cfg['ShowAll'] || $session_max_rows != 'all') - && !($is_count || $is_export || $is_func || $is_analyse) - && isset($analyzed_sql[0]['queryflags']['select_from']) - && !isset($analyzed_sql[0]['queryflags']['offset']) - && !preg_match('@[[:space:]]LIMIT[[:space:]0-9,-]+(;)?$@i', $sql_query)) { - $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'] . " "; - - $full_sql_query = $analyzed_sql[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit']; - // FIXME: pretty printing of this modified query - - if (isset($display_query)) { - // if the analysis of the original query revealed that we found - // a section_after_limit, we now have to analyze $display_query - // to display it correctly - - if (!empty($analyzed_sql[0]['section_after_limit']) && trim($analyzed_sql[0]['section_after_limit']) != ';') { - $analyzed_display_query = PMA_SQP_analyze(PMA_SQP_parse($display_query)); - $display_query = $analyzed_display_query[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_display_query[0]['section_after_limit']; - } +} else { + $full_sql_query = $sql_query; +} // end if...else + +if (isset($db)) { + PMA_DBI_select_db($db); +} + +// If the query is a DELETE query with no WHERE clause, get the number of +// rows that will be deleted (mysql_affected_rows will always return 0 in +// this case) +// Note: testing shows that this no longer applies since MySQL 4.0.x + +if (PMA_MYSQL_INT_VERSION < 40000) { + if ($is_delete + && preg_match('@^DELETE([[:space:]].+)?(FROM[[:space:]](.+))$@i', $sql_query, $parts) + && !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) { + $cnt_all_result = @PMA_DBI_try_query('SELECT COUNT(*) as count ' . $parts[2]); + if ($cnt_all_result) { + list($num_rows) = PMA_DBI_fetch_row($cnt_all_result); + PMA_DBI_free_result($cnt_all_result); + } else { + $num_rows = 0; } + } +} - } else { - $full_sql_query = $sql_query; - } // end if...else +// E x e c u t e t h e q u e r y + +// Only if we didn't ask to see the php code (mikebeck) +if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) { + unset($result); + $num_rows = 0; +} else { + // garvin: Measure query time. + // TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411 + $querytime_before = array_sum(explode(' ', microtime())); + + $result = @PMA_DBI_try_query($full_sql_query, null, PMA_DBI_QUERY_STORE); + + $querytime_after = array_sum(explode(' ', microtime())); + + $GLOBALS['querytime'] = $querytime_after - $querytime_before; - if (isset($db)) { - PMA_DBI_select_db($db); + // Displays an error message if required and stop parsing the script + if ($error = PMA_DBI_getError()) { + require_once './libraries/header.inc.php'; + $full_err_url = (preg_match('@^(db_details|tbl_properties)@', $err_url)) + ? $err_url . '&show_query=1&sql_query=' . urlencode($sql_query) + : $err_url; + PMA_mysqlDie($error, $full_sql_query, '', $full_err_url); } + unset($error); - // If the query is a DELETE query with no WHERE clause, get the number of - // rows that will be deleted (mysql_affected_rows will always return 0 in - // this case) - // Note: testing shows that this no longer applies since MySQL 4.0.x - - if (PMA_MYSQL_INT_VERSION < 40000) { - if ($is_delete - && preg_match('@^DELETE([[:space:]].+)?(FROM[[:space:]](.+))$@i', $sql_query, $parts) - && !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) { - $cnt_all_result = @PMA_DBI_try_query('SELECT COUNT(*) as count ' . $parts[2]); - if ($cnt_all_result) { - list($num_rows) = PMA_DBI_fetch_row($cnt_all_result); - PMA_DBI_free_result($cnt_all_result); - } else { - $num_rows = 0; - } - } + // Gets the number of rows affected/returned + // (This must be done immediately after the query because + // mysql_affected_rows() reports about the last query done) + + if (!$is_affected) { + $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0; + } elseif (!isset($num_rows)) { + $num_rows = @PMA_DBI_affected_rows(); } - // E x e c u t e t h e q u e r y + // Checks if the current database has changed + // This could happen if the user sends a query like "USE `database`;" + $res = PMA_DBI_query('SELECT DATABASE() AS \'db\';'); + $row = PMA_DBI_fetch_row($res); + if (isset($db) && is_array($row) && isset($row[0]) && (strcasecmp($db, $row[0]) != 0)) { + $db = $row[0]; + $reload = 1; + } + @PMA_DBI_free_result($res); + unset($res, $row); - // Only if we didn't ask to see the php code (mikebeck) - if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) { - unset($result); - $num_rows = 0; - } else { - // garvin: Measure query time. - // TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411 - $querytime_before = array_sum(explode(' ', microtime())); + // tmpfile remove after convert encoding appended by Y.Kawada + if (function_exists('PMA_kanji_file_conv') + && (isset($textfile) && file_exists($textfile))) { + unlink($textfile); + } - $result = @PMA_DBI_try_query($full_sql_query, null, PMA_DBI_QUERY_STORE); + // Counts the total number of rows for the same 'SELECT' query without the + // 'LIMIT' clause that may have been programatically added - $querytime_after = array_sum(explode(' ', microtime())); + if (empty($sql_limit_to_append)) { + $unlim_num_rows = $num_rows; + // if we did not append a limit, set this to get a correct + // "Showing rows..." message + $GLOBALS['session_max_rows'] = 'all'; + } elseif ($is_select) { - $GLOBALS['querytime'] = $querytime_after - $querytime_before; + // c o u n t q u e r y - // Displays an error message if required and stop parsing the script - if ($error = PMA_DBI_getError()) { - require_once './libraries/header.inc.php'; - $full_err_url = (preg_match('@^(db_details|tbl_properties)@', $err_url)) - ? $err_url . '&show_query=1&sql_query=' . urlencode($sql_query) - : $err_url; - PMA_mysqlDie($error, $full_sql_query, '', $full_err_url); - } - unset($error); + // If we are "just browsing", there is only one table, + // and no where clause (or just 'WHERE 1 '), + // so we do a quick count (which uses MaxExactCount) + // because SQL_CALC_FOUND_ROWS + // is not quick on large InnoDB tables - // Gets the number of rows affected/returned - // (This must be done immediately after the query because - // mysql_affected_rows() reports about the last query done) + // but do not count again if we did it previously + // due to $find_real_end == true - if (!$is_affected) { - $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0; - } elseif (!isset($num_rows)) { - $num_rows = @PMA_DBI_affected_rows(); - } + if (!$is_group + && !isset($analyzed_sql[0]['queryflags']['union']) + && !isset($analyzed_sql[0]['table_ref'][1]['table_name']) + && (empty($analyzed_sql[0]['where_clause']) + || $analyzed_sql[0]['where_clause'] == '1 ') + && !isset($find_real_end) + ) { - // Checks if the current database has changed - // This could happen if the user sends a query like "USE `database`;" - $res = PMA_DBI_query('SELECT DATABASE() AS \'db\';'); - $row = PMA_DBI_fetch_row($res); - if (isset($db) && is_array($row) && isset($row[0]) && (strcasecmp($db, $row[0]) != 0)) { - $db = $row[0]; - $reload = 1; - } - @PMA_DBI_free_result($res); - unset($res, $row); + // "j u s t b r o w s i n g" + $unlim_num_rows = PMA_Table::countRecords($db, $table, true); - // tmpfile remove after convert encoding appended by Y.Kawada - if (function_exists('PMA_kanji_file_conv') - && (isset($textfile) && file_exists($textfile))) { - unlink($textfile); - } + } else { // n o t " j u s t b r o w s i n g " - // Counts the total number of rows for the same 'SELECT' query without the - // 'LIMIT' clause that may have been programatically added - - if (empty($sql_limit_to_append)) { - $unlim_num_rows = $num_rows; - // if we did not append a limit, set this to get a correct - // "Showing rows..." message - $GLOBALS['session_max_rows'] = 'all'; - } elseif ($is_select) { - - // c o u n t q u e r y - - // If we are "just browsing", there is only one table, - // and no where clause (or just 'WHERE 1 '), - // so we do a quick count (which uses MaxExactCount) - // because SQL_CALC_FOUND_ROWS - // is not quick on large InnoDB tables - - // but do not count again if we did it previously - // due to $find_real_end == true - - if (!$is_group - && !isset($analyzed_sql[0]['queryflags']['union']) - && !isset($analyzed_sql[0]['table_ref'][1]['table_name']) - && (empty($analyzed_sql[0]['where_clause']) - || $analyzed_sql[0]['where_clause'] == '1 ') - && !isset($find_real_end) - ) { - - // "j u s t b r o w s i n g" - $unlim_num_rows = PMA_Table::countRecords($db, $table, true); - - } else { // n o t " j u s t b r o w s i n g " - - if (PMA_MYSQL_INT_VERSION < 40000) { - - // detect this case: - // SELECT DISTINCT x AS foo, y AS bar FROM sometable - - if (isset($analyzed_sql[0]['queryflags']['distinct'])) { - $count_what = 'DISTINCT '; - $first_expr = true; - foreach ($analyzed_sql[0]['select_expr'] as $part) { - $count_what .= (!$first_expr ? ', ' : '') . $part['expr']; - $first_expr = false; - } - } else { - $count_what = '*'; - } - // this one does not apply to VIEWs - $count_query = 'SELECT COUNT(' . $count_what . ') AS count'; - } + if (PMA_MYSQL_INT_VERSION < 40000) { - // add the remaining of select expression if there is - // a GROUP BY or HAVING clause - if (PMA_MYSQL_INT_VERSION < 40000 - && $count_what =='*' - && (!empty($analyzed_sql[0]['group_by_clause']) - || !empty($analyzed_sql[0]['having_clause']))) { - $count_query .= ' ,' . $analyzed_sql[0]['select_expr_clause']; - } + // detect this case: + // SELECT DISTINCT x AS foo, y AS bar FROM sometable - if (PMA_MYSQL_INT_VERSION >= 40000) { - // add select expression after the SQL_CALC_FOUND_ROWS - - // for UNION, just adding SQL_CALC_FOUND_ROWS - // after the first SELECT works. - - // take the left part, could be: - // SELECT - // (SELECT - $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1); - $count_query .= ' SQL_CALC_FOUND_ROWS '; - // add everything that was after the first SELECT - $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1); - // ensure there is no semicolon at the end of the - // count query because we'll probably add - // a LIMIT 1 clause after it - $count_query = rtrim($count_query); - $count_query = rtrim($count_query, ';'); - } else { // PMA_MYSQL_INT_VERSION < 40000 - - if (!empty($analyzed_sql[0]['from_clause'])) { - $count_query .= ' FROM ' . $analyzed_sql[0]['from_clause']; + if (isset($analyzed_sql[0]['queryflags']['distinct'])) { + $count_what = 'DISTINCT '; + $first_expr = true; + foreach ($analyzed_sql[0]['select_expr'] as $part) { + $count_what .= (!$first_expr ? ', ' : '') . $part['expr']; + $first_expr = false; } - if (!empty($analyzed_sql[0]['where_clause'])) { - $count_query .= ' WHERE ' . $analyzed_sql[0]['where_clause']; - } - if (!empty($analyzed_sql[0]['group_by_clause'])) { - $count_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause']; - } - if (!empty($analyzed_sql[0]['having_clause'])) { - $count_query .= ' HAVING ' . $analyzed_sql[0]['having_clause']; - } - } // end if + } else { + $count_what = '*'; + } + // this one does not apply to VIEWs + $count_query = 'SELECT COUNT(' . $count_what . ') AS count'; + } - // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid - // long delays. Returned count will be complete anyway. - // (but a LIMIT would disrupt results in an UNION) + // add the remaining of select expression if there is + // a GROUP BY or HAVING clause + if (PMA_MYSQL_INT_VERSION < 40000 + && $count_what =='*' + && (!empty($analyzed_sql[0]['group_by_clause']) + || !empty($analyzed_sql[0]['having_clause']))) { + $count_query .= ' ,' . $analyzed_sql[0]['select_expr_clause']; + } - if (PMA_MYSQL_INT_VERSION >= 40000 - && !isset($analyzed_sql[0]['queryflags']['union'])) { - $count_query .= ' LIMIT 1'; + if (PMA_MYSQL_INT_VERSION >= 40000) { + // add select expression after the SQL_CALC_FOUND_ROWS + + // for UNION, just adding SQL_CALC_FOUND_ROWS + // after the first SELECT works. + + // take the left part, could be: + // SELECT + // (SELECT + $count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1); + $count_query .= ' SQL_CALC_FOUND_ROWS '; + // add everything that was after the first SELECT + $count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1); + // ensure there is no semicolon at the end of the + // count query because we'll probably add + // a LIMIT 1 clause after it + $count_query = rtrim($count_query); + $count_query = rtrim($count_query, ';'); + } else { // PMA_MYSQL_INT_VERSION < 40000 + + if (!empty($analyzed_sql[0]['from_clause'])) { + $count_query .= ' FROM ' . $analyzed_sql[0]['from_clause']; + } + if (!empty($analyzed_sql[0]['where_clause'])) { + $count_query .= ' WHERE ' . $analyzed_sql[0]['where_clause']; } + if (!empty($analyzed_sql[0]['group_by_clause'])) { + $count_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause']; + } + if (!empty($analyzed_sql[0]['having_clause'])) { + $count_query .= ' HAVING ' . $analyzed_sql[0]['having_clause']; + } + } // end if - // run the count query - - if (PMA_MYSQL_INT_VERSION < 40000) { - if ($cnt_all_result = PMA_DBI_try_query($count_query)) { - if ($is_group && $count_what == '*') { - $unlim_num_rows = @PMA_DBI_num_rows($cnt_all_result); - } else { - $unlim_num_rows = PMA_DBI_fetch_assoc($cnt_all_result); - $unlim_num_rows = $unlim_num_rows['count']; - } - PMA_DBI_free_result($cnt_all_result); + // if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid + // long delays. Returned count will be complete anyway. + // (but a LIMIT would disrupt results in an UNION) + + if (PMA_MYSQL_INT_VERSION >= 40000 + && !isset($analyzed_sql[0]['queryflags']['union'])) { + $count_query .= ' LIMIT 1'; + } + + // run the count query + + if (PMA_MYSQL_INT_VERSION < 40000) { + if ($cnt_all_result = PMA_DBI_try_query($count_query)) { + if ($is_group && $count_what == '*') { + $unlim_num_rows = @PMA_DBI_num_rows($cnt_all_result); } else { - if (PMA_DBI_getError()) { - - // there are some cases where the generated - // count_query (for MySQL 3) is wrong, - // so we get here. - //TODO: use a big unlimited query to get - // the correct number of rows (depending - // on a config variable?) - $unlim_num_rows = 0; - } + $unlim_num_rows = PMA_DBI_fetch_assoc($cnt_all_result); + $unlim_num_rows = $unlim_num_rows['count']; } + PMA_DBI_free_result($cnt_all_result); } else { - PMA_DBI_try_query($count_query); - // if (mysql_error()) { - // void. - // I tried the case - // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`) - // UNION (SELECT `User`, `Host`, "%" AS "Db", - // `Select_priv` - // FROM `user`) ORDER BY `User`, `Host`, `Db`; - // and although the generated count_query is wrong - // the SELECT FOUND_ROWS() work! (maybe it gets the - // count from the latest query that worked) - // - // another case where the count_query is wrong: - // SELECT COUNT(*), f1 from t1 group by f1 - // and you click to sort on count(*) - // } - $cnt_all_result = PMA_DBI_query('SELECT FOUND_ROWS() as count;'); - list($unlim_num_rows) = PMA_DBI_fetch_row($cnt_all_result); - @PMA_DBI_free_result($cnt_all_result); + if (PMA_DBI_getError()) { + + // there are some cases where the generated + // count_query (for MySQL 3) is wrong, + // so we get here. + /** + * @todo use a big unlimited query to get the correct + * number of rows (depending on a config variable?) + */ + $unlim_num_rows = 0; + } } - } // end else "just browsing" - - } else { // not $is_select - $unlim_num_rows = 0; - } // end rows total count - - // garvin: if a table or database gets dropped, check column comments. - if (isset($purge) && $purge == '1') { - require_once './libraries/relation_cleanup.lib.php'; - - if (isset($table) && isset($db) && strlen($table) && strlen($db)) { - PMA_relationsCleanupTable($db, $table); - } elseif (isset($db) && strlen($db)) { - PMA_relationsCleanupDatabase($db); - } else { - // garvin: VOID. No DB/Table gets deleted. - } // end if relation-stuff - } // end if ($purge) - - // garvin: If a column gets dropped, do relation magic. - if (isset($cpurge) && $cpurge == '1' && isset($purgekey) - && isset($db) && isset($table) - && strlen($db) && strlen($table) && !empty($purgekey)) { - require_once './libraries/relation_cleanup.lib.php'; - PMA_relationsCleanupColumn($db, $table, $purgekey); - - } // end if column PMA_* purge - } // end else "didn't ask to see php code" - - // No rows returned -> move back to the calling page - if ($num_rows < 1 || $is_affected) { - if ($is_delete) { - $message = $strDeletedRows . ' ' . $num_rows; - } elseif ($is_insert) { - if ($is_replace) { - /* For replace we get DELETED + INSERTED row count, so we have to call it affected */ - $message = $strAffectedRows . ' ' . $num_rows; - } else { - $message = $strInsertedRows . ' ' . $num_rows; - } - $insert_id = PMA_DBI_insert_id(); - if ($insert_id != 0) { - // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this - $message .= '[br]'.$strInsertedRowId . ' ' . ($insert_id + $num_rows - 1); - } - } elseif ($is_affected) { - $message = $strAffectedRows . ' ' . $num_rows; + } else { + PMA_DBI_try_query($count_query); + // if (mysql_error()) { + // void. + // I tried the case + // (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`) + // UNION (SELECT `User`, `Host`, "%" AS "Db", + // `Select_priv` + // FROM `user`) ORDER BY `User`, `Host`, `Db`; + // and although the generated count_query is wrong + // the SELECT FOUND_ROWS() work! (maybe it gets the + // count from the latest query that worked) + // + // another case where the count_query is wrong: + // SELECT COUNT(*), f1 from t1 group by f1 + // and you click to sort on count(*) + // } + $cnt_all_result = PMA_DBI_query('SELECT FOUND_ROWS() as count;'); + list($unlim_num_rows) = PMA_DBI_fetch_row($cnt_all_result); + @PMA_DBI_free_result($cnt_all_result); + } + } // end else "just browsing" + + } else { // not $is_select + $unlim_num_rows = 0; + } // end rows total count + + // garvin: if a table or database gets dropped, check column comments. + if (isset($purge) && $purge == '1') { + require_once './libraries/relation_cleanup.lib.php'; - // Ok, here is an explanation for the !$is_select. - // The form generated by sql_query_form.lib.php - // and db_details.php has many submit buttons - // on the same form, and some confusion arises from the - // fact that $zero_rows is sent for every case. - // The $zero_rows containing $strSuccess and sent with - // the form should not have priority over - // errors like $strEmptyResultSet - } elseif (!empty($zero_rows) && !$is_select) { - $message = $zero_rows; - } elseif (!empty($GLOBALS['show_as_php'])) { - $message = $strPhp; - } elseif (!empty($GLOBALS['validatequery'])) { - $message = $strValidateSQL; + if (isset($table) && isset($db) && strlen($table) && strlen($db)) { + PMA_relationsCleanupTable($db, $table); + } elseif (isset($db) && strlen($db)) { + PMA_relationsCleanupDatabase($db); } else { - $message = $strEmptyResultSet; + // garvin: VOID. No DB/Table gets deleted. + } // end if relation-stuff + } // end if ($purge) + + // garvin: If a column gets dropped, do relation magic. + if (isset($cpurge) && $cpurge == '1' && isset($purgekey) + && isset($db) && isset($table) + && strlen($db) && strlen($table) && !empty($purgekey)) { + require_once './libraries/relation_cleanup.lib.php'; + PMA_relationsCleanupColumn($db, $table, $purgekey); + + } // end if column PMA_* purge +} // end else "didn't ask to see php code" + +// No rows returned -> move back to the calling page +if ($num_rows < 1 || $is_affected) { + if ($is_delete) { + $message = $strDeletedRows . ' ' . $num_rows; + } elseif ($is_insert) { + if ($is_replace) { + /* For replace we get DELETED + INSERTED row count, so we have to call it affected */ + $message = $strAffectedRows . ' ' . $num_rows; + } else { + $message = $strInsertedRows . ' ' . $num_rows; } + $insert_id = PMA_DBI_insert_id(); + if ($insert_id != 0) { + // insert_id is id of FIRST record inserted in one insert, so if we inserted multiple rows, we had to increment this + $message .= '[br]'.$strInsertedRowId . ' ' . ($insert_id + $num_rows - 1); + } + } elseif ($is_affected) { + $message = $strAffectedRows . ' ' . $num_rows; + + // Ok, here is an explanation for the !$is_select. + // The form generated by sql_query_form.lib.php + // and db_details.php has many submit buttons + // on the same form, and some confusion arises from the + // fact that $zero_rows is sent for every case. + // The $zero_rows containing $strSuccess and sent with + // the form should not have priority over + // errors like $strEmptyResultSet + } elseif (!empty($zero_rows) && !$is_select) { + $message = $zero_rows; + } elseif (!empty($GLOBALS['show_as_php'])) { + $message = $strPhp; + } elseif (!empty($GLOBALS['validatequery'])) { + $message = $strValidateSQL; + } else { + $message = $strEmptyResultSet; + } - $message .= ' ' . (isset($GLOBALS['querytime']) ? '(' . sprintf($strQueryTime, $GLOBALS['querytime']) . ')' : ''); + $message .= ' ' . (isset($GLOBALS['querytime']) ? '(' . sprintf($strQueryTime, $GLOBALS['querytime']) . ')' : ''); - if ($is_gotofile) { - $goto = PMA_securePath($goto); - // Checks for a valid target script - $is_db = $is_table = false; - include 'libraries/db_table_exists.lib.php'; - if (strpos($goto, 'tbl_properties') === 0 && ! $is_table) { - if (isset($table)) { - unset($table); - } - $goto = 'db_details.php'; - } - if (strpos($goto, 'db_details') === 0 && ! $is_db) { - if (isset($db)) { - unset($db); - } - $goto = 'main.php'; - } - // Loads to target script - if (strpos($goto, 'db_details') === 0 - || strpos($goto, 'tbl_properties') === 0) { - $js_to_run = 'functions.js'; + if ($is_gotofile) { + $goto = PMA_securePath($goto); + // Checks for a valid target script + $is_db = $is_table = false; + include 'libraries/db_table_exists.lib.php'; + if (strpos($goto, 'tbl_properties') === 0 && ! $is_table) { + if (isset($table)) { + unset($table); } - if ($goto != 'main.php') { - require_once './libraries/header.inc.php'; + $goto = 'db_details.php'; + } + if (strpos($goto, 'db_details') === 0 && ! $is_db) { + if (isset($db)) { + unset($db); } - $active_page = $goto; - require './' . $goto; - } else { - PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto) . '&message=' . urlencode($message)); - } // end else - exit(); - } // end no rows returned - - // At least one row is returned -> displays a table with results - else { - // Displays the headers - if (isset($show_query)) { - unset($show_query); + $goto = 'main.php'; } - if (isset($printview) && $printview == '1') { - require_once './libraries/header_printview.inc.php'; - } else { + // Loads to target script + if (strpos($goto, 'db_details') === 0 + || strpos($goto, 'tbl_properties') === 0) { $js_to_run = 'functions.js'; - unset($message); - if (isset($table) && strlen($table)) { - require './libraries/tbl_properties_common.php'; - $url_query .= '&goto=tbl_properties.php&back=tbl_properties.php'; - require './libraries/tbl_properties_table_info.inc.php'; - require './libraries/tbl_properties_links.inc.php'; - } elseif (isset($db) && strlen($db)) { - require './libraries/db_details_common.inc.php'; - require './libraries/db_details_db_info.inc.php'; - } else { - require './libraries/server_common.inc.php'; - require './libraries/server_links.inc.php'; - } } - - if (isset($db) && strlen($db)) { - require_once './libraries/relation.lib.php'; - $cfgRelation = PMA_getRelationsParam(); + if ($goto != 'main.php') { + require_once './libraries/header.inc.php'; } + $active_page = $goto; + require './' . $goto; + } else { + PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . str_replace('&', '&', $goto) . '&message=' . urlencode($message)); + } // end else + exit(); +} // end no rows returned - // Gets the list of fields properties - if (isset($result) && $result) { - $fields_meta = PMA_DBI_get_fields_meta($result); - $fields_cnt = count($fields_meta); +// At least one row is returned -> displays a table with results +else { + // Displays the headers + if (isset($show_query)) { + unset($show_query); + } + if (isset($printview) && $printview == '1') { + require_once './libraries/header_printview.inc.php'; + } else { + $js_to_run = 'functions.js'; + unset($message); + if (isset($table) && strlen($table)) { + require './libraries/tbl_properties_common.php'; + $url_query .= '&goto=tbl_properties.php&back=tbl_properties.php'; + require './libraries/tbl_properties_table_info.inc.php'; + require './libraries/tbl_properties_links.inc.php'; + } elseif (isset($db) && strlen($db)) { + require './libraries/db_details_common.inc.php'; + require './libraries/db_details_db_info.inc.php'; + } else { + require './libraries/server_common.inc.php'; + require './libraries/server_links.inc.php'; } + } - // Display previous update query (from tbl_replace) - if (isset($disp_query) && $cfg['ShowSQL'] == true) { - $tmp_sql_query = $GLOBALS['sql_query']; - $GLOBALS['sql_query'] = $disp_query; - PMA_showMessage($disp_message); - $GLOBALS['sql_query'] = $tmp_sql_query; - } + if (isset($db) && strlen($db)) { + require_once './libraries/relation.lib.php'; + $cfgRelation = PMA_getRelationsParam(); + } - // Displays the results in a table - require_once './libraries/display_tbl.lib.php'; - if (empty($disp_mode)) { - // see the "PMA_setDisplayMode()" function in - // libraries/display_tbl.lib.php - $disp_mode = 'urdr111101'; - } - if (!isset($dontlimitchars)) { - $dontlimitchars = 0; - } + // Gets the list of fields properties + if (isset($result) && $result) { + $fields_meta = PMA_DBI_get_fields_meta($result); + $fields_cnt = count($fields_meta); + } - // hide edit and delete links for information_schema - if (PMA_MYSQL_INT_VERSION >= 50002 && isset($db) && $db == 'information_schema') { - $disp_mode = 'nnnn110111'; - } + // Display previous update query (from tbl_replace) + if (isset($disp_query) && $cfg['ShowSQL'] == true) { + $tmp_sql_query = $GLOBALS['sql_query']; + $GLOBALS['sql_query'] = $disp_query; + PMA_showMessage($disp_message); + $GLOBALS['sql_query'] = $tmp_sql_query; + } - PMA_displayTable($result, $disp_mode, $analyzed_sql); - PMA_DBI_free_result($result); + // Displays the results in a table + require_once './libraries/display_tbl.lib.php'; + if (empty($disp_mode)) { + // see the "PMA_setDisplayMode()" function in + // libraries/display_tbl.lib.php + $disp_mode = 'urdr111101'; + } + if (!isset($dontlimitchars)) { + $dontlimitchars = 0; + } - // BEGIN INDEX CHECK See if indexes should be checked. - if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) { - foreach ($selected AS $idx => $tbl_name) { - $indexes = $indexes_info = $indexes_data = array(); - $tbl_ret_keys = PMA_get_indexes(urldecode($tbl_name), $err_url_0); + // hide edit and delete links for information_schema + if (PMA_MYSQL_INT_VERSION >= 50002 && isset($db) && $db == 'information_schema') { + $disp_mode = 'nnnn110111'; + } + + PMA_displayTable($result, $disp_mode, $analyzed_sql); + PMA_DBI_free_result($result); + + // BEGIN INDEX CHECK See if indexes should be checked. + if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) { + foreach ($selected AS $idx => $tbl_name) { + $indexes = $indexes_info = $indexes_data = array(); + $tbl_ret_keys = PMA_get_indexes(urldecode($tbl_name), $err_url_0); - PMA_extract_indexes($tbl_ret_keys, $indexes, $indexes_info, $indexes_data); + PMA_extract_indexes($tbl_ret_keys, $indexes, $indexes_info, $indexes_data); - $idx_collection = PMA_show_indexes(urldecode($tbl_name), $indexes, $indexes_info, $indexes_data, false); - $check = PMA_check_indexes($idx_collection); - if (!empty($check)) { + $idx_collection = PMA_show_indexes(urldecode($tbl_name), $indexes, $indexes_info, $indexes_data, false); + $check = PMA_check_indexes($idx_collection); + if (!empty($check)) { ?> <table border="0" cellpadding="2" cellspacing="0"> <tr> @@ -724,27 +735,27 @@ else { <?php echo $check; ?> </table> <?php - } } - } // End INDEX CHECK - - // Bookmark Support if required - if ($disp_mode[7] == '1' - && (isset($cfg['Bookmark']) && $cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark)) - && !empty($sql_query)) { - echo "\n"; - - $goto = 'sql.php?' - . PMA_generate_common_url($db, $table) - . '&pos=' . $pos - . '&session_max_rows=' . $session_max_rows - . '&disp_direction=' . $disp_direction - . '&repeat_cells=' . $repeat_cells - . '&dontlimitchars=' . $dontlimitchars - . '&sql_query=' . urlencode($sql_query) - . '&id_bookmark=1'; - - ?> + } + } // End INDEX CHECK + + // Bookmark Support if required + if ($disp_mode[7] == '1' + && (isset($cfg['Bookmark']) && $cfg['Bookmark']['db'] && $cfg['Bookmark']['table'] && empty($id_bookmark)) + && !empty($sql_query)) { + echo "\n"; + + $goto = 'sql.php?' + . PMA_generate_common_url($db, $table) + . '&pos=' . $pos + . '&session_max_rows=' . $session_max_rows + . '&disp_direction=' . $disp_direction + . '&repeat_cells=' . $repeat_cells + . '&dontlimitchars=' . $dontlimitchars + . '&sql_query=' . urlencode($sql_query) + . '&id_bookmark=1'; + + ?> <form action="sql.php" method="post" onsubmit="return emptyFormElements(this, 'fields[label]');"> <?php echo PMA_generate_common_hidden_inputs(); ?> <input type="hidden" name="goto" value="<?php echo $goto; ?>" /> @@ -774,12 +785,12 @@ else { <input type="submit" name="store_bkm" value="<?php echo $strBookmarkThis; ?>" /> </fieldset> </form> - <?php - } // end bookmark support + <?php + } // end bookmark support - // Do print the page if required - if (isset($printview) && $printview == '1') { - ?> + // Do print the page if required + if (isset($printview) && $printview == '1') { + ?> <script type="text/javascript" language="javascript"> //<![CDATA[ // Do print the page @@ -791,11 +802,9 @@ window.onload = function() } //]]> </script> - <?php - } // end print case - } // end rows returned - -} // end executes the query + <?php + } // end print case +} // end rows returned /** * Displays the footer diff --git a/tbl_alter.php b/tbl_alter.php index cc92eab89d..e7ae9b2eef 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -165,7 +165,9 @@ if ($abort == FALSE) { $selected_cnt = count($selected); } - // TODO: optimize in case of multiple fields to modify + /** + * @todo optimize in case of multiple fields to modify + */ for ($i = 0; $i < $selected_cnt; $i++) { if (!empty($submit_mult)) { $field = PMA_sqlAddslashes(urldecode($selected[$i]), TRUE); @@ -184,11 +186,13 @@ if ($abort == FALSE) { // but later, if the analyser returns more information, it // could be executed for any MySQL version and replace // the info given by SHOW FULL FIELDS FROM. - // TODO: put this code into a require() - // or maybe make it part of PMA_DBI_get_fields(); + /** + * @todo put this code into a require() + * or maybe make it part of PMA_DBI_get_fields(); + */ // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since - // SHOW FULL FIELDS says NULL and SHOW CREATE TABLE says NOT NULL (tested + // SHOW FULL FIELDS says NULL and SHOW CREATE TABLE says NOT NULL (tested // in MySQL 4.0.25). $show_create_table = PMA_DBI_fetch_value( diff --git a/tbl_change.php b/tbl_change.php index f7136179b9..19aa643ea7 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -80,7 +80,9 @@ if (!empty($disp_message)) { if (empty($goto)) { $goto = 'db_details.php'; } -// TODO: check if we could replace by "db_details|tbl" +/** + * @todo check if we could replace by "db_details|tbl" + */ if (!preg_match('@^(db_details|tbl_properties|tbl_select|tbl_import)@', $goto)) { $err_url = $goto . "?" . PMA_generate_common_url($db) . "&sql_query=" . urlencode($sql_query); } else { @@ -808,7 +810,10 @@ foreach ($loop_array AS $vrowcount => $vrow) { echo '<input type="file" name="fields_upload_' . urlencode($field) . $vkey . '" class="textfield" id="field_' . ($idindex) . '_3" size="10" /> '; // find maximum upload size, based on field type - // FIXME: with functions this is not so easy, as you can basically process any data with function like MD5 + /** + * @todo with functions this is not so easy, as you can basically + * process any data with function like MD5 + */ $max_field_sizes = array( 'tinyblob' => '256', 'blob' => '65536', @@ -942,9 +947,9 @@ if (isset($primary_key)) { <option value="same_insert" <?php echo ($after_insert == 'same_insert' ? 'selected="selected"' : ''); ?>><?php echo $strAfterInsertSame; ?></option> <?php // If we have just numeric primary key, we can also edit next - // in 2.8.2, we were looking for `field_name` = numeric_value + // in 2.8.2, we were looking for `field_name` = numeric_value //if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $primary_key)) { - // in 2.9.0, we are looking for `table_name`.`field_name` = numeric_value + // in 2.9.0, we are looking for `table_name`.`field_name` = numeric_value if (preg_match('@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@', $primary_key)) { ?> <option value="edit_next"><?php echo $strAfterInsertNext; ?></option> diff --git a/tbl_printview.php b/tbl_printview.php index 26154b2f34..3b3e3b9f3c 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -110,7 +110,7 @@ foreach ($the_tables as $key => $table) { PMA_DBI_QUERY_STORE); $fields_cnt = PMA_DBI_num_rows($result); - + // We need this to correctly learn if a TIMESTAMP is NOT NULL, since // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL // and SHOW CREATE TABLE says NOT NULL (tested @@ -220,10 +220,12 @@ foreach ($the_tables as $key => $table) { // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe // the latter. - // TODO: merge this logic with the one in tbl_properties_structure.php - // or move it in a function similar to PMA_DBI_get_columns_full() - // but based on SHOW CREATE TABLE because information_schema - // cannot be trusted in this case (MySQL bug) + /** + * @todo merge this logic with the one in tbl_properties_structure.php + * or move it in a function similar to PMA_DBI_get_columns_full() + * but based on SHOW CREATE TABLE because information_schema + * cannot be trusted in this case (MySQL bug) + */ if (!empty($analyzed_sql[0]['create_table_fields'][$field_name]['type']) && $analyzed_sql[0]['create_table_fields'][$field_name]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$field_name]['timestamp_not_null']) { $row['Null'] = ''; } diff --git a/tbl_replace.php b/tbl_replace.php index cea0737155..aa78eb561e 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -276,8 +276,9 @@ if ($total_affected_rows != 0) { $message .= $last_message; if (!empty($warning_message)) { - // TODO: use a <div class="warning"> in PMA_showMessage() - // for this part of the message + /** + * @todo use a <div class="warning"> in PMA_showMessage() for this part of the message + */ $message .= '[br]' . $warning_message; } |