Merge pull request #18416 from kamil-tekiela/18414
Fix #18414: Use empty string as sentinel instead of false
This commit is contained in:
commit
9528590aa4
@ -477,9 +477,9 @@ class Relation
|
||||
* @param string $db the name of the db to check for
|
||||
* @param string $table the name of the table to check for
|
||||
*
|
||||
* @return string|false field name or false
|
||||
* @return string field name
|
||||
*/
|
||||
public function getDisplayField(string $db, string $table): string|false
|
||||
public function getDisplayField(string $db, string $table): string
|
||||
{
|
||||
$displayFeature = $this->getRelationParameters()->displayFeature;
|
||||
|
||||
@ -522,7 +522,7 @@ class Relation
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1028,7 +1028,7 @@ class Relation
|
||||
|
||||
$fQueryMain = 'SELECT ' . Util::backquote($foreignField)
|
||||
. (
|
||||
$foreignDisplay === false
|
||||
$foreignDisplay === ''
|
||||
? ''
|
||||
: ', ' . Util::backquote($foreignDisplay)
|
||||
);
|
||||
@ -1040,14 +1040,14 @@ class Relation
|
||||
'%' . $this->dbi->escapeMysqlWildcards($foreignFilter) . '%',
|
||||
)
|
||||
. (
|
||||
$foreignDisplay === false
|
||||
$foreignDisplay === ''
|
||||
? ''
|
||||
: ' OR ' . Util::backquote($foreignDisplay)
|
||||
. ' LIKE ' . $this->dbi->quoteString(
|
||||
'%' . $this->dbi->escapeMysqlWildcards($foreignFilter) . '%',
|
||||
)
|
||||
);
|
||||
$fQueryOrder = $foreignDisplay === false ? '' : ' ORDER BY '
|
||||
$fQueryOrder = $foreignDisplay === '' ? '' : ' ORDER BY '
|
||||
. Util::backquote($foreignTable) . '.'
|
||||
. Util::backquote($foreignDisplay);
|
||||
|
||||
|
||||
@ -58,7 +58,6 @@ class Common
|
||||
|
||||
foreach ($tables as $oneTable) {
|
||||
$df = $this->relation->getDisplayField($db, $oneTable['TABLE_NAME']);
|
||||
$df = is_string($df) ? $df : '';
|
||||
$df = $df !== '' ? $df : null;
|
||||
$designerTables[] = new DesignerTable(
|
||||
$db,
|
||||
|
||||
@ -4119,14 +4119,14 @@ class Results
|
||||
}
|
||||
|
||||
if (isset($map[$meta->name])) {
|
||||
/** @var array{0: string, 1: string, 2: string|false, 3: string} $relation */
|
||||
/** @var array{0: string, 1: string, 2: string, 3: string} $relation */
|
||||
$relation = $map[$meta->name];
|
||||
// Field to display from the foreign table?
|
||||
$dispval = '';
|
||||
|
||||
// Check that we have a valid column name
|
||||
// Relation::getDisplayField() returns false by default
|
||||
if ($relation[2] !== '' && $relation[2] !== false) {
|
||||
if ($relation[2] !== '') {
|
||||
$dispval = $this->getFromForeign($relation, $whereComparison);
|
||||
}
|
||||
|
||||
@ -4158,7 +4158,7 @@ class Results
|
||||
// always apply a transformation on the real data,
|
||||
// not on the display field
|
||||
$displayedData = $transformationPlugin->applyTransformation($data, $transformOptions, $meta);
|
||||
} elseif ($relationalDisplay === self::RELATIONAL_DISPLAY_COLUMN && $relation[2]) {
|
||||
} elseif ($relationalDisplay === self::RELATIONAL_DISPLAY_COLUMN && $relation[2] !== '') {
|
||||
// user chose "relational display field" in the
|
||||
// display options, so show display field in the cell
|
||||
$displayedData = $dispval === null ? '<em>NULL</em>' : Core::mimeDefaultFunction($dispval);
|
||||
|
||||
@ -1102,7 +1102,7 @@ class InsertEdit
|
||||
|
||||
$displayField = $this->relation->getDisplayField($foreigner['foreign_db'], $foreigner['foreign_table']);
|
||||
// Field to display from the foreign table?
|
||||
if (is_string($displayField) && $displayField !== '') {
|
||||
if ($displayField !== '') {
|
||||
$dispsql = 'SELECT ' . Util::backquote($displayField)
|
||||
. ' FROM ' . Util::backquote($foreigner['foreign_db'])
|
||||
. '.' . Util::backquote($foreigner['foreign_table'])
|
||||
|
||||
@ -656,7 +656,7 @@ parameters:
|
||||
path: libraries/classes/ConfigStorage/Relation.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:getDisplayField\\(\\) should return string\\|false but returns mixed\\.$#"
|
||||
message: "#^Method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:getDisplayField\\(\\) should return string but returns mixed\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/ConfigStorage/Relation.php
|
||||
|
||||
|
||||
@ -778,7 +778,7 @@
|
||||
</MixedAssignment>
|
||||
<MixedInferredReturnType>
|
||||
<code>array|false</code>
|
||||
<code>string|false</code>
|
||||
<code>string</code>
|
||||
</MixedInferredReturnType>
|
||||
<MixedReturnStatement>
|
||||
<code><![CDATA[$column['COLUMN_NAME']]]></code>
|
||||
|
||||
@ -52,7 +52,8 @@ class RelationTest extends AbstractTestCase
|
||||
|
||||
$db = 'information_schema';
|
||||
$table = 'PMA';
|
||||
$this->assertFalse(
|
||||
$this->assertSame(
|
||||
'',
|
||||
$relation->getDisplayField($db, $table),
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user