Skip to content

Commit

Permalink
Remove the table change 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 42468cb commit d190c82
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
14 changes: 12 additions & 2 deletions libraries/classes/Controllers/Table/ReplaceController.php
Expand Up @@ -388,7 +388,7 @@ public function index(): void
$message = Message::success(__('No change'));
// Avoid infinite recursion
if ($goto_include == 'libraries/entry_points/table/replace.php') {
$goto_include = 'libraries/entry_points/table/change.php';
$goto_include = '/table/change';
}
$active_page = $goto_include;

Expand All @@ -402,6 +402,11 @@ public function index(): void
$controller = $containerBuilder->get(DatabaseSqlController::class);
$controller->index();
return;
} elseif ($goto_include === '/table/change') {
/** @var ChangeController $controller */
$controller = $containerBuilder->get(ChangeController::class);
$controller->index();
return;
}

include ROOT_PATH . Core::securePath((string) $goto_include);
Expand Down Expand Up @@ -438,7 +443,7 @@ public function index(): void
);
}
if ($row_skipped) {
$goto_include = 'libraries/entry_points/table/change.php';
$goto_include = '/table/change';
$message->addMessagesString($insert_errors, '<br>');
$message->isError(true);
}
Expand Down Expand Up @@ -590,6 +595,11 @@ public function index(): void
$controller = $containerBuilder->get(DatabaseSqlController::class);
$controller->index();
return;
} elseif ($goto_include === '/table/change') {
/** @var ChangeController $controller */
$controller = $containerBuilder->get(ChangeController::class);
$controller->index();
return;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions libraries/classes/Controllers/Table/RowActionController.php
Expand Up @@ -21,7 +21,7 @@ class RowActionController extends AbstractController
*/
public function index(): void
{
global $db, $goto, $pmaThemeImage, $sql_query, $table;
global $containerBuilder, $db, $goto, $pmaThemeImage, $sql_query, $table;
global $submit_mult, $active_page, $err_url, $original_sql_query, $url_query, $original_url_query;
global $disp_message, $disp_query, $single_table, $where_clause, $action;

Expand Down Expand Up @@ -100,7 +100,9 @@ public function index(): void
}
}
$active_page = Url::getFromRoute('/table/change');
include ROOT_PATH . 'libraries/entry_points/table/change.php';
/** @var ChangeController $controller */
$controller = $containerBuilder->get(ChangeController::class);
$controller->index();
break;

case 'row_export':
Expand Down
9 changes: 7 additions & 2 deletions libraries/classes/InsertEdit.php
Expand Up @@ -8,6 +8,7 @@

namespace PhpMyAdmin;

use PhpMyAdmin\Controllers\Table\ChangeController;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Plugins\TransformationsPlugin;

Expand Down Expand Up @@ -2181,6 +2182,8 @@ public function getParamsForUpdateOrInsert()
*/
public function isInsertRow()
{
global $containerBuilder;

if (isset($_POST['insert_rows'])
&& is_numeric($_POST['insert_rows'])
&& $_POST['insert_rows'] != $GLOBALS['cfg']['InsertRows']
Expand All @@ -2192,7 +2195,9 @@ public function isInsertRow()
$scripts->addFile('vendor/jquery/additional-methods.js');
$scripts->addFile('table/change.js');
if (! defined('TESTSUITE')) {
include ROOT_PATH . 'libraries/entry_points/table/change.php';
/** @var ChangeController $controller */
$controller = $containerBuilder->get(ChangeController::class);
$controller->index();
exit;
}
}
Expand Down Expand Up @@ -2252,7 +2257,7 @@ public function getGotoInclude($goto_include)
if (isset($_POST['after_insert'])
&& in_array($_POST['after_insert'], $valid_options)
) {
$goto_include = 'libraries/entry_points/table/change.php';
$goto_include = '/table/change';
} elseif (! empty($GLOBALS['goto'])) {
if (! preg_match('@^[a-z_]+\.php$@', $GLOBALS['goto'])) {
// this should NOT happen
Expand Down
17 changes: 0 additions & 17 deletions libraries/entry_points/table/change.php

This file was deleted.

2 changes: 1 addition & 1 deletion test/classes/InsertEditTest.php
Expand Up @@ -2619,7 +2619,7 @@ public function testGetGotoInclude()

$_POST['after_insert'] = 'new_insert';
$this->assertEquals(
'libraries/entry_points/table/change.php',
'/table/change',
$this->insertEdit->getGotoInclude('index')
);
}
Expand Down

0 comments on commit d190c82

Please sign in to comment.