Fixes: #12241 Fixes: #15316 Fixes: #14691 Fixes: #13187 Fixes: #14612 Fixes: #13222 Closes: #13296 Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
commit
b39d22b35e
@ -53,33 +53,6 @@ if (! empty($sql_query)) {
|
||||
if ((!empty($parser->statements[0]))
|
||||
&& ($parser->statements[0] instanceof PhpMyAdmin\SqlParser\Statements\SelectStatement)
|
||||
) {
|
||||
|
||||
// Finding aliases and removing them, but we keep track of them to be
|
||||
// able to replace them in select expression too.
|
||||
$aliases = array();
|
||||
foreach ($parser->statements[0]->from as $from) {
|
||||
if ((!empty($from->table)) && (!empty($from->alias))) {
|
||||
$aliases[$from->alias] = $from->table;
|
||||
// We remove the alias of the table because they are going to
|
||||
// be replaced anyway.
|
||||
$from->alias = null;
|
||||
$from->expr = null; // Force rebuild.
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuilding the SELECT and FROM clauses.
|
||||
if (count($parser->statements[0]->from) > 0
|
||||
&& count($parser->statements[0]->union) === 0
|
||||
) {
|
||||
$replaces = array(
|
||||
array(
|
||||
'FROM', 'FROM ' . PhpMyAdmin\SqlParser\Components\ExpressionArray::build(
|
||||
$parser->statements[0]->from
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Checking if the WHERE clause has to be replaced.
|
||||
if ((!empty($where_clause)) && (is_array($where_clause))) {
|
||||
$replaces[] = array(
|
||||
@ -96,28 +69,6 @@ if (! empty($sql_query)) {
|
||||
$parser->list,
|
||||
$replaces
|
||||
);
|
||||
|
||||
// Removing the aliases by finding the alias followed by a dot.
|
||||
$tokens = PhpMyAdmin\SqlParser\Lexer::getTokens($sql_query);
|
||||
foreach ($aliases as $alias => $table) {
|
||||
$tokens = PhpMyAdmin\SqlParser\Utils\Tokens::replaceTokens(
|
||||
$tokens,
|
||||
array(
|
||||
array(
|
||||
'value_str' => $alias,
|
||||
),
|
||||
array(
|
||||
'type' => PhpMyAdmin\SqlParser\Token::TYPE_OPERATOR,
|
||||
'value_str' => '.',
|
||||
)
|
||||
),
|
||||
array(
|
||||
new PhpMyAdmin\SqlParser\Token($table),
|
||||
new PhpMyAdmin\SqlParser\Token('.',PhpMyAdmin\SqlParser\Token::TYPE_OPERATOR)
|
||||
)
|
||||
);
|
||||
}
|
||||
$sql_query = PhpMyAdmin\SqlParser\TokensList::build($tokens);
|
||||
}
|
||||
|
||||
echo PhpMyAdmin\Util::getMessage(PhpMyAdmin\Message::success());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user