From eae51ef7c73e1baefd2af00ee9da769eb255802b Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 6 Jan 2016 12:14:13 -0500 Subject: [PATCH] Fixes #11780 FROM clause not generated after loading search bookmark Signed-off-by: Marc Delisle --- ChangeLog | 1 + libraries/DBQbe.class.php | 23 +++++++++++++++-------- test/classes/PMA_DBQbe_test.php | 5 +++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40ba51c9c0..a17b23844b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ phpMyAdmin - ChangeLog - issue #11727 SQL duplicate entry error trying to INSERT in designer_settings table - issue #11798 Fix handling of databases with dot in a name - issue #11820 Fix hiding of page content behind menu +- issue #11780 FROM clause not generated after loading search bookmark 4.5.3.1 (2015-12-25) - issue #11774 Undefined offset 2 diff --git a/libraries/DBQbe.class.php b/libraries/DBQbe.class.php index 86cdba0dc2..c138783395 100644 --- a/libraries/DBQbe.class.php +++ b/libraries/DBQbe.class.php @@ -1530,14 +1530,14 @@ class PMA_DbQbe /** * Provides FROM clause for building SQL query * + * @param array $curField List of selected columns + * * @return string FROM clause */ - private function _getFromClause() + private function _getFromClause($curField) { $from_clause = ''; - if (!isset($_POST['criteriaColumn']) - || count($_POST['criteriaColumn']) <= 0 - ) { + if (empty($curField)) { return $from_clause; } @@ -1545,7 +1545,7 @@ class PMA_DbQbe $search_tables = $search_columns = array(); // We only start this if we have fields, otherwise it would be dumb - foreach ($_POST['criteriaColumn'] as $value) { + foreach ($curField as $value) { $parts = explode('.', $value); if (! empty($parts[0]) && ! empty($parts[1])) { $table = str_replace('`', '', $parts[0]); @@ -1782,15 +1782,17 @@ class PMA_DbQbe /** * Provides the generated SQL query * + * @param array $curField List of selected columns + * * @return string SQL query */ - private function _getSQLQuery() + private function _getSQLQuery($curField) { $sql_query = ''; // get SELECT clause $sql_query .= $this->_getSelectClause(); // get FROM clause - $from_clause = $this->_getFromClause(); + $from_clause = $this->_getFromClause($curField); if (! empty($from_clause)) { $sql_query .= 'FROM ' . htmlspecialchars($from_clause) . "\n"; } @@ -1854,7 +1856,12 @@ class PMA_DbQbe $html_output .= ''; $html_output .= ''; // displays form's footers diff --git a/test/classes/PMA_DBQbe_test.php b/test/classes/PMA_DBQbe_test.php index 5b19bcadc3..ffd62d4135 100644 --- a/test/classes/PMA_DBQbe_test.php +++ b/test/classes/PMA_DBQbe_test.php @@ -514,7 +514,8 @@ class PMA_DBQbe_Test extends PHPUnit_Framework_TestCase $this->assertEquals( '`table1`', $this->_callProtectedFunction( - '_getFromClause', array() + '_getFromClause', + array(array('`table1`.`id`')) ) ); } @@ -537,7 +538,7 @@ class PMA_DBQbe_Test extends PHPUnit_Framework_TestCase ', $this->_callProtectedFunction( '_getSQLQuery', - array() + array(array('`table1`.`id`')) ) ); }