Fixes #11780 FROM clause not generated after loading search bookmark

Signed-off-by: Marc Delisle <marc@infomarc.info>
This commit is contained in:
Marc Delisle 2016-01-06 12:14:13 -05:00
parent fdcf305834
commit eae51ef7c7
3 changed files with 19 additions and 10 deletions

View File

@ -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

View File

@ -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 .= '<textarea cols="80" name="sql_query" id="textSqlquery"'
. ' rows="' . ((count($this->_criteriaTables) > 30) ? '15' : '7') . '"'
. ' dir="' . $text_dir . '">';
$html_output .= $this->_getSQLQuery();
if (empty($this->_curField)) {
$this->_curField = array();
}
$html_output .= $this->_getSQLQuery($this->_curField);
$html_output .= '</textarea>';
$html_output .= '</fieldset>';
// displays form's footers

View File

@ -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`'))
)
);
}