Skip to content

Commit

Permalink
Merge #16274 - Fix #16194 - SQL query does not appear in case of edit…
Browse files Browse the repository at this point in the history
…ing view where definer is not you on MySQL 8

Pull-request: #16274
Fixes: #16194
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Jul 23, 2020
2 parents 38c09bc + b47c706 commit 0099860
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions view_create.php
Expand Up @@ -13,6 +13,9 @@
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Statements\CreateStatement;
use PhpMyAdmin\SqlParser\TokensList;
use PhpMyAdmin\Template;
use PhpMyAdmin\Util;

Expand Down Expand Up @@ -225,6 +228,15 @@
$view['as'] = $item['VIEW_DEFINITION'];
$view['with'] = $item['CHECK_OPTION'];
$view['algorithm'] = $item['ALGORITHM'];

if (empty($view['as']) && is_string($createView)) {
$parser = new Parser($createView);
/**
* @var CreateStatement $stmt
*/
$stmt = $parser->statements[0];
$view['as'] = isset($stmt->body) ? TokensList::build($stmt->body) : $view['as'];
}
}

if (Core::isValid($_POST['view'], 'array')) {
Expand Down

0 comments on commit 0099860

Please sign in to comment.