Skip to content

Commit

Permalink
Remove the database sql entry point file
Browse files Browse the repository at this point in the history
Directly calls the controller instead of including the file.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Jan 7, 2020
1 parent bb42779 commit 42468cb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 28 deletions.
11 changes: 11 additions & 0 deletions libraries/classes/Controllers/Table/ReplaceController.php
Expand Up @@ -6,6 +6,7 @@

namespace PhpMyAdmin\Controllers\Table;

use PhpMyAdmin\Controllers\Database\SqlController as DatabaseSqlController;
use PhpMyAdmin\Controllers\SqlController;
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
Expand Down Expand Up @@ -396,6 +397,11 @@ public function index(): void
$controller = $containerBuilder->get(SqlController::class);
$controller->index();
return;
} elseif ($goto_include === '/database/sql') {
/** @var DatabaseSqlController $controller */
$controller = $containerBuilder->get(DatabaseSqlController::class);
$controller->index();
return;
}

include ROOT_PATH . Core::securePath((string) $goto_include);
Expand Down Expand Up @@ -579,6 +585,11 @@ public function index(): void
$controller = $containerBuilder->get(SqlController::class);
$controller->index();
return;
} elseif ($goto_include === '/database/sql') {
/** @var DatabaseSqlController $controller */
$controller = $containerBuilder->get(DatabaseSqlController::class);
$controller->index();
return;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions libraries/classes/InsertEdit.php
Expand Up @@ -2265,13 +2265,13 @@ public function getGotoInclude($goto_include)
} else {
$goto_include = $GLOBALS['goto'];
}
if ($GLOBALS['goto'] == 'libraries/entry_points/database/sql.php' && strlen($GLOBALS['table']) > 0) {
if ($GLOBALS['goto'] == 'index.php?route=/database/sql' && strlen($GLOBALS['table']) > 0) {
$GLOBALS['table'] = '';
}
}
if (! $goto_include) {
if (strlen($GLOBALS['table']) === 0) {
$goto_include = 'libraries/entry_points/database/sql.php';
$goto_include = '/database/sql';
} else {
$goto_include = 'libraries/entry_points/table/sql.php';
}
Expand Down
7 changes: 5 additions & 2 deletions libraries/db_table_exists.inc.php
Expand Up @@ -7,6 +7,7 @@
*/
declare(strict_types=1);

use PhpMyAdmin\Controllers\Database\SqlController;
use PhpMyAdmin\Core;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
Expand All @@ -16,7 +17,7 @@
exit;
}

global $db, $table, $dbi, $is_db, $is_table, $message, $show_as_php, $sql_query;
global $containerBuilder, $db, $table, $dbi, $is_db, $is_table, $message, $show_as_php, $sql_query;

if (empty($is_db)) {
if (strlen($db) > 0) {
Expand Down Expand Up @@ -101,7 +102,9 @@
}

if (! $is_table) {
include ROOT_PATH . 'libraries/entry_points/database/sql.php';
/** @var SqlController $controller */
$controller = $containerBuilder->get(SqlController::class);
$controller->index();
exit;
}
}
Expand Down
21 changes: 0 additions & 21 deletions libraries/entry_points/database/sql.php

This file was deleted.

6 changes: 3 additions & 3 deletions test/classes/InsertEditTest.php
Expand Up @@ -2595,7 +2595,7 @@ public function testGetGotoInclude()
$GLOBALS['table'] = '';

$this->assertEquals(
'libraries/entry_points/database/sql.php',
'/database/sql',
$this->insertEdit->getGotoInclude('index')
);

Expand All @@ -2605,10 +2605,10 @@ public function testGetGotoInclude()
$this->insertEdit->getGotoInclude('index')
);

$GLOBALS['goto'] = 'libraries/entry_points/database/sql.php';
$GLOBALS['goto'] = 'index.php?route=/database/sql';

$this->assertEquals(
'libraries/entry_points/database/sql.php',
'/database/sql',
$this->insertEdit->getGotoInclude('index')
);

Expand Down

0 comments on commit 42468cb

Please sign in to comment.