Skip to content

Commit 0690993

Browse files
Merge pull request #17444 from kamil-tekiela/Refactor-importSQL
Refactor import sql
2 parents 88ae2a2 + 6181dca commit 0690993

24 files changed

Lines changed: 213 additions & 406 deletions

libraries/classes/Controllers/Import/ImportController.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public function __invoke(): void
100100
$GLOBALS['reset_charset'] = $GLOBALS['reset_charset'] ?? null;
101101
$GLOBALS['result'] = $GLOBALS['result'] ?? null;
102102
$GLOBALS['import_file_name'] = $GLOBALS['import_file_name'] ?? null;
103-
$GLOBALS['sql_data'] = $GLOBALS['sql_data'] ?? null;
104103
$GLOBALS['import_notice'] = $GLOBALS['import_notice'] ?? null;
105104
$GLOBALS['read_multiply'] = $GLOBALS['read_multiply'] ?? null;
106105
$GLOBALS['my_die'] = $GLOBALS['my_die'] ?? null;
@@ -597,10 +596,7 @@ public function __invoke(): void
597596

598597
// This array contain the data like number of valid sql queries in the statement
599598
// and complete valid sql statement (which affected for rows)
600-
$GLOBALS['sql_data'] = [
601-
'valid_sql' => [],
602-
'valid_queries' => 0,
603-
];
599+
$queriesToBeExecuted = [];
604600

605601
if (! $GLOBALS['error']) {
606602
/**
@@ -624,7 +620,7 @@ public function __invoke(): void
624620
// Do the real import
625621
$default_fk_check = ForeignKey::handleDisableCheckInit();
626622
try {
627-
$import_plugin->doImport($importHandle ?? null, $GLOBALS['sql_data']);
623+
$queriesToBeExecuted = $import_plugin->doImport($importHandle ?? null);
628624
ForeignKey::handleDisableCheckCleanup($default_fk_check);
629625
} catch (Throwable $e) {
630626
ForeignKey::handleDisableCheckCleanup($default_fk_check);
@@ -741,16 +737,15 @@ public function __invoke(): void
741737
}
742738

743739
if ($GLOBALS['go_sql']) {
744-
if (! empty($GLOBALS['sql_data']) && ($GLOBALS['sql_data']['valid_queries'] > 1)) {
740+
if ($queriesToBeExecuted !== []) {
745741
$_SESSION['is_multi_query'] = true;
746-
$sql_queries = $GLOBALS['sql_data']['valid_sql'];
747742
} else {
748-
$sql_queries = [$GLOBALS['sql_query']];
743+
$queriesToBeExecuted = [$GLOBALS['sql_query']];
749744
}
750745

751746
$html_output = '';
752747

753-
foreach ($sql_queries as $GLOBALS['sql_query']) {
748+
foreach ($queriesToBeExecuted as $GLOBALS['sql_query']) {
754749
// parse sql query
755750
[
756751
$analyzed_sql_results,

libraries/classes/Controllers/Sql/SqlController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public function __invoke(): void
6161
$GLOBALS['disp_query'] = $GLOBALS['disp_query'] ?? null;
6262
$GLOBALS['extra_data'] = $GLOBALS['extra_data'] ?? null;
6363
$GLOBALS['message_to_show'] = $GLOBALS['message_to_show'] ?? null;
64-
$GLOBALS['sql_data'] = $GLOBALS['sql_data'] ?? null;
6564
$GLOBALS['disp_message'] = $GLOBALS['disp_message'] ?? null;
6665
$GLOBALS['complete_query'] = $GLOBALS['complete_query'] ?? null;
6766
$GLOBALS['is_gotofile'] = $GLOBALS['is_gotofile'] ?? null;
@@ -216,7 +215,7 @@ public function __invoke(): void
216215
$GLOBALS['import_text'] ?? null,
217216
$GLOBALS['extra_data'] ?? null,
218217
$GLOBALS['message_to_show'] ?? null,
219-
$GLOBALS['sql_data'] ?? null,
218+
null,
220219
$GLOBALS['goto'],
221220
isset($GLOBALS['disp_query']) ? $GLOBALS['display_query'] : null,
222221
$GLOBALS['disp_message'] ?? null,

0 commit comments

Comments
 (0)