Merge pull request #19307 from kamil-tekiela/getForeignersInternal

Split getForeigners into getForeignersInternal
This commit is contained in:
Maurício Meneghini Fauth 2024-09-30 14:22:38 -03:00 committed by GitHub
commit 45dc64801d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 31 additions and 60 deletions

View File

@ -10682,12 +10682,12 @@ parameters:
-
message: "#^Cannot access offset mixed on mixed\\.$#"
count: 13
count: 3
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
message: "#^Cannot access offset string on mixed\\.$#"
count: 4
count: 14
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
@ -10720,11 +10720,6 @@ parameters:
count: 3
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
message: "#^Parameter \\#1 \\$txt of method TCPDF\\:\\:Bookmark\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
message: "#^Parameter \\#1 \\$value of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\PdfRelationSchema\\:\\:setTableOrder\\(\\) expects string, mixed given\\.$#"
count: 1
@ -10740,31 +10735,6 @@ parameters:
count: 1
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:getComments\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:getForeigners\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\DatabaseInterface\\:\\:getColumns\\(\\) expects string, mixed given\\.$#"
count: 2
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Transformations\\:\\:getMime\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
message: "#^Parameter \\#2 \\$tableName of method PhpMyAdmin\\\\DatabaseInterface\\:\\:getTable\\(\\) expects string, mixed given\\.$#"
count: 1
path: src/Plugins/Schema/Pdf/PdfRelationSchema.php
-
message: "#^Parameter \\#4 \\$foreignField of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\PdfRelationSchema\\:\\:addRelation\\(\\) expects string, mixed given\\.$#"
count: 1

View File

@ -9238,9 +9238,6 @@
<MixedArgument>
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
<code><![CDATA[$rel['foreign_field']]]></code>
<code><![CDATA[$table]]></code>
<code><![CDATA[$table]]></code>
<code><![CDATA[$table]]></code>
<code><![CDATA[$this->pdf->customLinks['RT']['-']]]></code>
<code><![CDATA[$this->pdf->customLinks['doc'][$table][$fieldName]]]></code>
<code><![CDATA[$this->pdf->customLinks['doc'][$table]['-']]]></code>
@ -9272,20 +9269,15 @@
</MixedArrayAssignment>
<MixedArrayOffset>
<code><![CDATA[$foreignTable[$foreigner['foreign_field']]]]></code>
<code><![CDATA[$this->pdf->customLinks['RT'][$table]]]></code>
<code><![CDATA[$this->pdf->customLinks['doc'][$foreigner['foreign_table']]]]></code>
<code><![CDATA[$this->pdf->customLinks['doc'][$foreigner['foreign_table']]]]></code>
<code><![CDATA[$this->pdf->customLinks['doc'][$foreigner['foreign_table']][$foreigner['foreign_field']]]]></code>
<code><![CDATA[$this->pdf->customLinks['doc'][$table]]]></code>
<code><![CDATA[$this->pdf->customLinks['doc'][$table]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$attribute]]></code>
<code><![CDATA[$foreignTable]]></code>
<code><![CDATA[$links[0]]]></code>
<code><![CDATA[$links[6]]]></code>
<code><![CDATA[$table]]></code>
<code><![CDATA[$table]]></code>
<code><![CDATA[$type]]></code>
</MixedAssignment>
<MixedOperand>
@ -9294,8 +9286,6 @@
<code><![CDATA[$foreigner['foreign_table']]]></code>
<code><![CDATA[$foreigner['on_delete']]]></code>
<code><![CDATA[$foreigner['on_update']]]></code>
<code><![CDATA[$table]]></code>
<code><![CDATA[$table]]></code>
</MixedOperand>
<PossiblyInvalidArgument>
<code><![CDATA[$_REQUEST['pdf_table_order']]]></code>

View File

@ -369,12 +369,27 @@ class Relation
* @param string $db the name of the db to check for
* @param string $table the name of the table to check for
* @param string $column the name of the column to check for
* @param string $source the source for foreign key information
* @psalm-param 'both'|'internal' $source
*
* @return array<array<mixed>>
*/
public function getForeigners(string $db, string $table, string $column = '', string $source = 'both'): array
public function getForeigners(string $db, string $table, string $column = ''): array
{
$foreign = $this->getForeignersInternal($db, $table, $column);
if ($table !== '') {
$foreign['foreign_keys_data'] = $this->getForeignKeysData($db, $table);
}
return $foreign;
}
/**
* Gets all Relations to foreign tables for a given table or
* optionally a given column in a table
*
* @return array<array<mixed>>
*/
public function getForeignersInternal(string $db, string $table, string $column = ''): array
{
$relationFeature = $this->getRelationParameters()->relationFeature;
$foreign = [];
@ -394,10 +409,6 @@ class Relation
$foreign = $this->dbi->fetchResult($relQuery, 'master_field', null, ConnectionType::ControlUser);
}
if ($source === 'both' && $table !== '') {
$foreign['foreign_keys_data'] = $this->getForeignKeysData($db, $table);
}
/**
* Emulating relations for some information_schema tables
*/

View File

@ -66,7 +66,7 @@ final class RelationController implements InvocableController
$relations = [];
if ($relationParameters->relationFeature !== null) {
$relations = $this->relation->getForeigners(Current::$database, Current::$table, '', 'internal');
$relations = $this->relation->getForeignersInternal(Current::$database, Current::$table);
}
$relationsForeign = [];
@ -149,7 +149,7 @@ final class RelationController implements InvocableController
// If we did an update, refresh our data
if (isset($_POST['destination_db']) && $relationParameters->relationFeature !== null) {
$relations = $this->relation->getForeigners(Current::$database, Current::$table, '', 'internal');
$relations = $this->relation->getForeignersInternal(Current::$database, Current::$table);
}
if (isset($_POST['destination_foreign_db']) && ForeignKey::isSupported($storageEngine)) {

View File

@ -116,7 +116,7 @@ class Common
while ($val = $allTabRs->fetchRow()) {
$val = (string) $val[0];
$row = $this->relation->getForeigners(Current::$database, $val, '', 'internal');
$row = $this->relation->getForeignersInternal(Current::$database, $val);
foreach ($row as $field => $value) {
$con['C_NAME'][$i] = '';

View File

@ -3478,7 +3478,7 @@ class Results
// the name related to a numeric id).
$map = [];
foreach ($this->relation->getForeigners($this->db, $this->table, '', 'internal') as $masterField => $rel) {
foreach ($this->relation->getForeignersInternal($this->db, $this->table) as $masterField => $rel) {
$map[$masterField] = new ForeignKeyRelatedTable(
$rel['foreign_table'],
$rel['foreign_field'],

View File

@ -555,7 +555,7 @@ class Operations
$foreigners = [];
$this->dbi->selectDb(Current::$database);
$foreign = $this->relation->getForeigners(Current::$database, Current::$table, '', 'internal');
$foreign = $this->relation->getForeignersInternal(Current::$database, Current::$table);
foreach ($foreign as $master => $arr) {
$joinQuery = 'SELECT '

View File

@ -1778,7 +1778,7 @@ class ExportSql extends ExportPlugin
// Check if we can use Relations
$foreigners = $doRelation && $relationParameters->relationFeature !== null ?
$this->relation->getForeigners($db, $table, '', 'internal')
$this->relation->getForeignersInternal($db, $table)
: [];
if ($foreigners !== []) {

View File

@ -92,7 +92,7 @@ class DiaRelationSchema extends ExportRelationSchema
$seenARelation = false;
foreach ($alltables as $oneTable) {
$existRel = $this->relation->getForeigners($this->db->getName(), $oneTable, '', 'internal');
$existRel = $this->relation->getForeignersInternal($this->db->getName(), $oneTable);
$seenARelation = true;
foreach ($existRel as $masterField => $rel) {

View File

@ -98,7 +98,7 @@ class EpsRelationSchema extends ExportRelationSchema
$seenARelation = false;
foreach ($alltables as $oneTable) {
$existRel = $this->relation->getForeigners($this->db->getName(), $oneTable, '', 'internal');
$existRel = $this->relation->getForeignersInternal($this->db->getName(), $oneTable);
$seenARelation = true;
foreach ($existRel as $masterField => $rel) {

View File

@ -196,7 +196,7 @@ class PdfRelationSchema extends ExportRelationSchema
// and finding its foreigns is OK (then we can support innodb)
$seenARelation = false;
foreach ($alltables as $oneTable) {
$existRel = $this->relation->getForeigners($this->db->getName(), $oneTable, '', 'internal');
$existRel = $this->relation->getForeignersInternal($this->db->getName(), $oneTable);
$seenARelation = true;
foreach ($existRel as $masterField => $rel) {
@ -438,7 +438,7 @@ class PdfRelationSchema extends ExportRelationSchema
/**
* Generates data dictionary pages.
*
* @param mixed[] $alltables Tables to document.
* @param string[] $alltables Tables to document.
*/
public function dataDictionaryDoc(array $alltables): void
{

View File

@ -113,7 +113,7 @@ class SvgRelationSchema extends ExportRelationSchema
$seenARelation = false;
foreach ($alltables as $oneTable) {
$existRel = $this->relation->getForeigners($this->db->getName(), $oneTable, '', 'internal');
$existRel = $this->relation->getForeignersInternal($this->db->getName(), $oneTable);
if ($existRel === []) {
continue;
}