Skip to content

Commit b054d00

Browse files
Merge pull request #17807 from kamil-tekiela/table-dbi
Pass $dbi as argument to Table
2 parents c76bb77 + 2c41612 commit b054d00

15 files changed

Lines changed: 66 additions & 69 deletions

File tree

‎libraries/classes/ConfigStorage/Relation.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public function getForeigners($db, $table, $column = '', $source = 'both')
439439
}
440440

441441
if (($source === 'both' || $source === 'foreign') && strlen($table) > 0) {
442-
$tableObj = new Table($table, $db);
442+
$tableObj = new Table($table, $db, $this->dbi);
443443
$show_create_table = $tableObj->showCreate();
444444
if ($show_create_table) {
445445
$parser = new Parser($show_create_table);

‎libraries/classes/Controllers/Table/RelationController.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,10 @@ public function __invoke(ServerRequest $request): void
162162

163163
$uniqueColumns = [];
164164
if ($foreignDb && $foreignTable) {
165-
$tableObject = Table::get(
165+
$tableObject = new Table(
166166
$foreignTable,
167-
$foreignDb
167+
$foreignDb,
168+
$this->dbi
168169
);
169170
$uniqueColumns = $tableObject->getUniqueColumns(false, false);
170171
}

‎libraries/classes/Controllers/Table/ReplaceController.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ private function doTransformations(array $mimeMap): void
489489
);
490490

491491
/**Get the total row count of the table*/
492-
$_table = new Table($_POST['table'], $_POST['db']);
492+
$_table = new Table($_POST['table'], $_POST['db'], $this->dbi);
493493
$extra_data['row_count'] = $_table->countRecords();
494494

495495
$extra_data['sql_query'] = Generator::getMessage($GLOBALS['message'], $GLOBALS['display_query']);

‎libraries/classes/Controllers/Table/Structure/PartitioningController.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function __invoke(ServerRequest $request): void
9191
*/
9292
private function extractPartitionDetails(): ?array
9393
{
94-
$createTable = (new Table($GLOBALS['table'], $GLOBALS['db']))->showCreate();
94+
$createTable = (new Table($GLOBALS['table'], $GLOBALS['db'], $this->dbi))->showCreate();
9595
if (! $createTable) {
9696
return null;
9797
}

‎libraries/classes/Database/Qbe.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ private function getMasterTable(
12901290
$result = '';
12911291
foreach ($candidateColumns as $table) {
12921292
if ($checkedTables[$table] != 1) {
1293-
$tableObj = new Table($table, $this->db);
1293+
$tableObj = new Table($table, $this->db, $this->dbi);
12941294
$tsize[$table] = $tableObj->countRecords();
12951295
$checkedTables[$table] = 1;
12961296
}

‎libraries/classes/Display/Results.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ private function setDisplayPartsAndTotal(DisplayParts $displayParts): array
626626
// - For a VIEW we (probably) did not count the number of rows
627627
// so don't test this number here, it would remove the possibility
628628
// of sorting VIEW results.
629-
$tableObject = new Table($table, $db);
629+
$tableObject = new Table($table, $db, $this->dbi);
630630
if ($unlimNumRows < 2 && ! $tableObject->isView()) {
631631
$displayParts = $displayParts->with(['hasSortLink' => false]);
632632
}
@@ -1193,7 +1193,7 @@ private function getDataForResettingColumnOrder(StatementInfo $statementInfo): a
11931193
[$columnOrder, $columnVisibility] = $this->getColumnParams($statementInfo);
11941194

11951195
$tableCreateTime = '';
1196-
$table = new Table($this->properties['table'], $this->properties['db']);
1196+
$table = new Table($this->properties['table'], $this->properties['db'], $this->dbi);
11971197
if (! $table->isView()) {
11981198
$tableCreateTime = $this->dbi->getTable(
11991199
$this->properties['db'],
@@ -2636,7 +2636,7 @@ private function getUrlSqlQuery(StatementInfo $statementInfo)
26362636
private function getColumnParams(StatementInfo $statementInfo): array
26372637
{
26382638
if ($this->isSelect($statementInfo)) {
2639-
$pmatable = new Table($this->properties['table'], $this->properties['db']);
2639+
$pmatable = new Table($this->properties['table'], $this->properties['db'], $this->dbi);
26402640
$colOrder = $pmatable->getUiProp(Table::PROP_COLUMN_ORDER);
26412641
$fieldsCount = $this->properties['fields_cnt'];
26422642
/* Validate the value */
@@ -3743,7 +3743,7 @@ private function setMessageInformation(
37433743
}
37443744

37453745
$messageViewWarning = false;
3746-
$table = new Table($this->properties['table'], $this->properties['db']);
3746+
$table = new Table($this->properties['table'], $this->properties['db'], $this->dbi);
37473747
if ($table->isView() && ($total == $GLOBALS['cfg']['MaxExactCountViews'])) {
37483748
$message = Message::notice(
37493749
__(

‎libraries/classes/Export.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ public function exportDatabase(
686686
$views = [];
687687

688688
foreach ($tables as $table) {
689-
$tableObject = new Table($table, $db);
689+
$tableObject = new Table($table, $db, $this->dbi);
690690
// if this is a view, collect it for later;
691691
// views must be exported after the tables
692692
$isView = $tableObject->isView();
@@ -764,7 +764,7 @@ public function exportDatabase(
764764
&& in_array($table, $tableData)
765765
&& ! $isView
766766
) {
767-
$tableObj = new Table($table, $db);
767+
$tableObj = new Table($table, $db, $this->dbi);
768768
$nonGeneratedCols = $tableObj->getNonGeneratedColumns(true);
769769

770770
$localQuery = 'SELECT ' . implode(', ', $nonGeneratedCols)
@@ -966,7 +966,7 @@ public function exportTable(
966966
$addQuery = '';
967967
}
968968

969-
$tableObject = new Table($table, $db);
969+
$tableObject = new Table($table, $db, $this->dbi);
970970
$isView = $tableObject->isView();
971971
if ($whatStrucOrData === 'structure' || $whatStrucOrData === 'structure_and_data') {
972972
if ($isView) {
@@ -1023,7 +1023,7 @@ public function exportTable(
10231023
$this->dbi->selectDb($db);
10241024
} else {
10251025
// Data is exported only for Non-generated columns
1026-
$tableObj = new Table($table, $db);
1026+
$tableObj = new Table($table, $db, $this->dbi);
10271027
$nonGeneratedCols = $tableObj->getNonGeneratedColumns(true);
10281028

10291029
$localQuery = 'SELECT ' . implode(', ', $nonGeneratedCols)

‎libraries/classes/Export/Options.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function getOptions(
131131

132132
$default = isset($_GET['what']) ? (string) $_GET['what'] : Plugins::getDefault('Export', 'format');
133133
$dropdown = Plugins::getChoice($exportList, $default);
134-
$tableObject = new Table($table, $db);
134+
$tableObject = new Table($table, $db, $GLOBALS['dbi']);
135135
$rows = [];
136136

137137
if (strlen($table) > 0 && empty($numTables) && ! $tableObject->isMerge() && $exportType !== 'raw') {

‎libraries/classes/Import.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ public function buildSql(
12471247

12481248
unset($params);
12491249

1250-
$tableObj = new Table($table[self::TBL_NAME], $dbName);
1250+
$tableObj = new Table($table[self::TBL_NAME], $dbName, $GLOBALS['dbi']);
12511251
if (! $tableObj->isView()) {
12521252
$message .= sprintf(
12531253
'<li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">' . __(

‎libraries/classes/Sql.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private function handleSortOrder(
9696
return $statementInfo;
9797
}
9898

99-
$tableObject = new Table($table, $db);
99+
$tableObject = new Table($table, $db, $this->dbi);
100100

101101
if (empty($statementInfo->order)) {
102102
// Retrieving the name of the column we should sort after.
@@ -1418,7 +1418,7 @@ private function getQueryResponseForResultsReturned(
14181418
$statement = $statementInfo->statement;
14191419
if ($statement instanceof SelectStatement) {
14201420
if ($statement->expr && $statement->expr[0]->expr === '*' && $table) {
1421-
$_table = new Table($table, $db);
1421+
$_table = new Table($table, $db, $this->dbi);
14221422
$updatableView = $_table->isUpdatableView();
14231423
}
14241424

@@ -1657,7 +1657,7 @@ public function executeQueryAndGetQueryResponse(
16571657
}
16581658

16591659
$displayResultsObject = new DisplayResults(
1660-
$GLOBALS['dbi'],
1660+
$this->dbi,
16611661
$GLOBALS['db'],
16621662
$GLOBALS['table'],
16631663
$GLOBALS['server'],
@@ -1775,7 +1775,7 @@ public function calculatePosForLastPage($db, $table, $pos)
17751775
$pos = $_SESSION['tmpval']['pos'];
17761776
}
17771777

1778-
$tableObject = new Table($table, $db);
1778+
$tableObject = new Table($table, $db, $this->dbi);
17791779
$unlimNumRows = $tableObject->countRecords(true);
17801780
//If position is higher than number of rows
17811781
if ($unlimNumRows <= $pos && $pos != 0) {

0 commit comments

Comments
 (0)