From 1aedeefc434b046d82a4131abf5447025e597f55 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sun, 3 Nov 2013 15:29:44 +0100 Subject: [PATCH 1/5] Update start position after a delete. --- libraries/mult_submits.lib.php | 2 ++ libraries/sql.lib.php | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/libraries/mult_submits.lib.php b/libraries/mult_submits.lib.php index 604c0696a2..ee373c7acb 100644 --- a/libraries/mult_submits.lib.php +++ b/libraries/mult_submits.lib.php @@ -267,6 +267,8 @@ function PMA_getQueryStrFromSelected( PMA_clearTransformations($db, $selected[$i]); } else if ($query_type == 'drop_fld') { PMA_clearTransformations($db, $table, $selected[$i]); + } elseif ($query_type == 'row_delete') { + //PMA_updatePos($db, $table); } } // end if } // end for diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index fbb3055ca1..92046d5180 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -1222,7 +1222,7 @@ function PMA_handleQueryExecuteError($is_gotofile, $error, $full_sql_query) * * @param String $db the current database * @param String $bkm_user the bookmarking user - * @param String $sql_query_for_bookmark the query to be stored in bookmark + * @param String $sql_query_for_bookmark the query to be stored in bookmark * @param String $bkm_label bookmark label * @param boolean $bkm_replace whether to replace existing bookmarks * @@ -2232,7 +2232,7 @@ function PMA_sendQueryResponse($num_rows, $unlim_num_rows, $is_affected, * @param string $db current database * @param string $table current table * @param bool $find_real_end whether to find real end or not - * @param string $sql_query_for_bookmark the sql query to be stored as bookmark + * @param string $sql_query_for_bookmark the sql query to be stored as bookmark * @param array $extra_data extra data * @param bool $is_affected whether affected or not * @param string $message_to_show message to show @@ -2335,4 +2335,24 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, isset($complete_query) ? $complete_query : null ); } + +/** + * Update pos if pos is higher than number of rows of displayed table + * + * @param String $db Database name + * @param String $table Table name + * + * @return Int Number of rows + */ +function PMA_updatePos($db, $table) +{ + $unlim_num_rows = PMA_Table::countRecords($db, $table, true); + //If position is higher than number of rows + if ($unlim_num_rows <= $_SESSION['tmpval']['pos']) { + PMA_findRealEndOfRows($db, $table); + } + + return $unlim_num_rows; +} + ?> From d3adbcaf05056158e85ee299c4fc8d5e35b528c6 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sun, 3 Nov 2013 16:02:50 +0100 Subject: [PATCH 2/5] Fix calculation of pos after delete. --- libraries/mult_submits.lib.php | 9 +++++++-- libraries/sql.lib.php | 30 ++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/libraries/mult_submits.lib.php b/libraries/mult_submits.lib.php index ee373c7acb..e337adf09e 100644 --- a/libraries/mult_submits.lib.php +++ b/libraries/mult_submits.lib.php @@ -98,10 +98,12 @@ function PMA_getQueryStrFromSelected( } $selected_cnt = count($selected); + $deletes = false; for ($i = 0; $i < $selected_cnt; $i++) { switch ($query_type) { case 'row_delete': + $deletes = true; $a_query = $selected[$i]; $run_parts = true; break; @@ -153,6 +155,7 @@ function PMA_getQueryStrFromSelected( break; case 'empty_tbl': + $deletes = true; $a_query = 'TRUNCATE '; $a_query .= PMA_Util::backquote($selected[$i]); $run_parts = true; @@ -267,12 +270,14 @@ function PMA_getQueryStrFromSelected( PMA_clearTransformations($db, $selected[$i]); } else if ($query_type == 'drop_fld') { PMA_clearTransformations($db, $table, $selected[$i]); - } elseif ($query_type == 'row_delete') { - //PMA_updatePos($db, $table); } } // end if } // end for + if ($deletes) { + $_REQUEST['pos'] = PMA_calculatePosForLastPage($db, $table, $_REQUEST['pos']); + } + return array( $result, $rebuild_database_list, $reload, $run_parts, $use_sql, $sql_query, $sql_query_views diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index 92046d5180..41e8383c3c 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -1050,9 +1050,7 @@ function PMA_addBookmark($pmaAbsoluteUri, $goto) function PMA_findRealEndOfRows($db, $table) { $unlim_num_rows = PMA_Table::countRecords($db, $table, true); - $_SESSION['tmpval']['pos'] = @((ceil( - $unlim_num_rows / $_SESSION['tmpval']['max_rows'] - ) - 1) * $_SESSION['tmpval']['max_rows']); + $_SESSION['tmpval']['pos'] = PMA_getStartPosToDisplayRow($unlim_num_rows); return $unlim_num_rows; } @@ -2337,22 +2335,38 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, } /** - * Update pos if pos is higher than number of rows of displayed table + * Function to define pos to display a row + * + * @param Int $number_of_line Number of the line to display + * + * @return Int Start position to display the line + */ +function PMA_getStartPosToDisplayRow($number_of_line) +{ + return @( + (ceil($number_of_line / $_SESSION['tmpval']['max_rows']) - 1) + * $_SESSION['tmpval']['max_rows'] + ); +} + +/** + * Function to calculate new pos if pos is higher than number of rows of displayed table * * @param String $db Database name * @param String $table Table name + * @param Int $pos Initial position * - * @return Int Number of rows + * @return Int Number of pos to display last page */ -function PMA_updatePos($db, $table) +function PMA_calculatePosForLastPage($db, $table, $pos = 0) { $unlim_num_rows = PMA_Table::countRecords($db, $table, true); //If position is higher than number of rows if ($unlim_num_rows <= $_SESSION['tmpval']['pos']) { - PMA_findRealEndOfRows($db, $table); + $pos = PMA_getStartPosToDisplayRow($unlim_num_rows); } - return $unlim_num_rows; + return $pos; } ?> From 12f1627656a1315690c6869015ef4953213b3373 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sun, 3 Nov 2013 19:19:15 +0100 Subject: [PATCH 3/5] Fix repositioning after delete. Fix test related to repositioning. --- libraries/sql.lib.php | 20 +++++++++++++------- test/libraries/PMA_mult_submits_test.php | 7 +++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index 41e8383c3c..3cb48f2ca0 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -2338,15 +2338,17 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, * Function to define pos to display a row * * @param Int $number_of_line Number of the line to display + * @param Int $max_rows Number of rows by page * * @return Int Start position to display the line */ -function PMA_getStartPosToDisplayRow($number_of_line) +function PMA_getStartPosToDisplayRow($number_of_line, $max_rows = null) { - return @( - (ceil($number_of_line / $_SESSION['tmpval']['max_rows']) - 1) - * $_SESSION['tmpval']['max_rows'] - ); + if (null === $max_rows) { + $max_rows = $_SESSION['tmpval']['max_rows']; + } + + return @((ceil($number_of_line / $max_rows) - 1) * $max_rows); } /** @@ -2358,11 +2360,15 @@ function PMA_getStartPosToDisplayRow($number_of_line) * * @return Int Number of pos to display last page */ -function PMA_calculatePosForLastPage($db, $table, $pos = 0) +function PMA_calculatePosForLastPage($db, $table, $pos) { + if (null === $pos) { + $pos = $_SESSION['tmpval']['pos']; + } + $unlim_num_rows = PMA_Table::countRecords($db, $table, true); //If position is higher than number of rows - if ($unlim_num_rows <= $_SESSION['tmpval']['pos']) { + if ($unlim_num_rows <= $pos && 0 != $pos) { $pos = PMA_getStartPosToDisplayRow($unlim_num_rows); } diff --git a/test/libraries/PMA_mult_submits_test.php b/test/libraries/PMA_mult_submits_test.php index 8464c5c8bf..f5adeff656 100644 --- a/test/libraries/PMA_mult_submits_test.php +++ b/test/libraries/PMA_mult_submits_test.php @@ -22,6 +22,8 @@ require_once 'libraries/sqlparser.lib.php'; require_once 'libraries/js_escape.lib.php'; require_once 'libraries/relation_cleanup.lib.php'; require_once 'libraries/relation.lib.php'; +require_once 'libraries/sql.lib.php'; +require_once 'libraries/Table.class.php'; /** * class PMA_MultSubmits_Test @@ -48,6 +50,7 @@ class PMA_MultSubmits_Test extends PHPUnit_Framework_TestCase $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; $GLOBALS['cfg']['LimitChars'] = 100; + $GLOBALS['cfg']['Server']['DisableIS'] = false; $GLOBALS['server'] = 0; $GLOBALS['cfg']['ActionLinksMode'] = "both"; $GLOBALS['pmaThemeImage'] = 'image'; @@ -278,6 +281,10 @@ class PMA_MultSubmits_Test extends PHPUnit_Framework_TestCase $from_prefix = "from_prefix"; $to_prefix = "to_prefix"; + $_REQUEST['pos'] = 1000; + $_SESSION['tmpval']['pos'] = 1000; + $_SESSION['tmpval']['max_rows'] = 25; + list( $result, $rebuild_database_list, $reload_ret, $run_parts, $use_sql, $sql_query, $sql_query_views From 5cb21ef969a497b7996c840f16c25d7d47008d75 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 5 Nov 2013 12:25:54 -0500 Subject: [PATCH 4/5] Fix coding style --- libraries/sql.lib.php | 49 ++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index 3cb48f2ca0..d9c57216bc 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -2225,29 +2225,29 @@ function PMA_sendQueryResponse($num_rows, $unlim_num_rows, $is_affected, /** * Function to execute the query and send the response * - * @param array $analyzed_sql_results analysed sql results - * @param bool $is_gotofile whether goto file or not - * @param string $db current database - * @param string $table current table - * @param bool $find_real_end whether to find real end or not + * @param array $analyzed_sql_results analysed sql results + * @param bool $is_gotofile whether goto file or not + * @param string $db current database + * @param string $table current table + * @param bool $find_real_end whether to find real end or not * @param string $sql_query_for_bookmark the sql query to be stored as bookmark - * @param array $extra_data extra data - * @param bool $is_affected whether affected or not - * @param string $message_to_show message to show - * @param string $disp_mode display mode - * @param string $message message - * @param array $sql_data sql data - * @param string $goto goto page url - * @param string $pmaThemeImage uri of the PMA theme image - * @param string $disp_query display query - * @param string $disp_message display message - * @param string $query_type query type - * @param string $sql_query sql query - * @param bool $selected whether check table, optimize table, analyze - * table or repair table has been selected with - * respect to the selected tables from the - * database structure page. - * @param string $complete_query complete query + * @param array $extra_data extra data + * @param bool $is_affected whether affected or not + * @param string $message_to_show message to show + * @param string $disp_mode display mode + * @param string $message message + * @param array $sql_data sql data + * @param string $goto goto page url + * @param string $pmaThemeImage uri of the PMA theme image + * @param string $disp_query display query + * @param string $disp_message display message + * @param string $query_type query type + * @param string $sql_query sql query + * @param bool $selected whether check table, optimize table, + * analyze table or repair table has been + * selected with respect to the selected + * tables from the database structure page + * @param string $complete_query complete query * * @return void */ @@ -2338,7 +2338,7 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, * Function to define pos to display a row * * @param Int $number_of_line Number of the line to display - * @param Int $max_rows Number of rows by page + * @param Int $max_rows Number of rows by page * * @return Int Start position to display the line */ @@ -2352,7 +2352,8 @@ function PMA_getStartPosToDisplayRow($number_of_line, $max_rows = null) } /** - * Function to calculate new pos if pos is higher than number of rows of displayed table + * Function to calculate new pos if pos is higher than number of rows + * of displayed table * * @param String $db Database name * @param String $table Table name From 32e237c15b2d2831f683be34d74a4eda603e727c Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 5 Nov 2013 12:26:39 -0500 Subject: [PATCH 5/5] ChangeLog entry for bug 4134 --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 617036af9b..1743e876c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -49,6 +49,7 @@ phpMyAdmin - ChangeLog + Javascript files are no longer uglified - bug #4145 Config screen fails to validate MemoryLimit = -1 (new default) - bug #4123 Double config including +- bug #4134 After deleting all rows on a page, it returns to a blank page 4.0.10.0 (not yet released) - bug #4150 Clicking database name in query window opens a new tab