Skip to content

Commit

Permalink
Fix #16942 - Table Import with CSV using LOAD DATA LOCAL causes error…
Browse files Browse the repository at this point in the history
… "LOAD DATA LOCAL INFILE is forbidden"

Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Aug 23, 2021
1 parent 90018d5 commit 84de4a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 0 additions & 6 deletions libraries/classes/Controllers/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
use Throwable;
use function define;
use function htmlspecialchars;
use function in_array;
use function ini_get;
Expand Down Expand Up @@ -88,11 +87,6 @@ public function index(): void
$local_import_file = $_POST['local_import_file'] ?? null;
$show_as_php = $_POST['show_as_php'] ?? null;

/* Enable LOAD DATA LOCAL INFILE for LDI plugin */
if ($format === 'ldi') {
define('PMA_ENABLE_LDI', 1);
}

// If there is a request to 'Simulate DML'.
if (isset($_POST['simulate_dml'])) {
$this->import->handleSimulateDmlRequest();
Expand Down
8 changes: 8 additions & 0 deletions libraries/common.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@
$auth_plugin = Plugins::getAuthPlugin();
$auth_plugin->authenticate();

/* Enable LOAD DATA LOCAL INFILE for LDI plugin */
if ($route === '/import' && ($_POST['format'] ?? '') === 'ldi') {
// Switch this before the DB connection is done
// phpcs:disable PSR1.Files.SideEffects
define('PMA_ENABLE_LDI', 1);
// phpcs:enable
}

Core::connectToDatabaseServer($dbi, $auth_plugin);

$auth_plugin->rememberCredentials();
Expand Down

0 comments on commit 84de4a6

Please sign in to comment.