Skip to content

Commit 3443891

Browse files
committed
Merge branch 'QA_5_2'
2 parents d621eca + de0244b commit 3443891

6 files changed

Lines changed: 232 additions & 25 deletions

File tree

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ phpMyAdmin - ChangeLog
3131
- issue #17257 Replace libraries/vendor_config.php constants with an array
3232

3333
5.1.4 (not yet released)
34+
- issue #17287 Fixed sorting the database list with "statistics" enabled on "Data" column creates a PHP type error
3435

3536
5.1.3 (2022-02-10)
3637
- issue #17308 Fix broken pagination links in the navigation sidebar

doc/config.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,27 @@ Server connection settings
630630
"phpMyAdmin " and either :config:option:`$cfg['Servers'][$i]['verbose']` or
631631
:config:option:`$cfg['Servers'][$i]['host']` will be used.
632632

633+
.. _servers_auth_swekey_config:
634+
.. config:option:: $cfg['Servers'][$i]['auth_swekey_config']
635+
636+
:type: string
637+
:default: ``''``
638+
639+
.. versionadded:: 3.0.0.0
640+
641+
This setting was named `$cfg['Servers'][$i]['auth_feebee_config']` and was renamed before the `3.0.0.0` release.
642+
643+
.. deprecated:: 4.6.4
644+
645+
This setting was removed because their servers are no longer working and it was not working correctly.
646+
647+
.. deprecated:: 4.0.10.17
648+
649+
This setting was removed in a maintenance release because their servers are no longer working and it was not working correctly.
650+
651+
The name of the file containing swekey ids and login names for hardware
652+
authentication. Leave empty to deactivate this feature.
653+
633654
.. _servers_user:
634655
.. config:option:: $cfg['Servers'][$i]['user']
635656

libraries/classes/Query/Utilities.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ public static function usortComparisonCallback(array $a, array $b, string $sortB
145145

146146
// produces f.e.:
147147
// return -1 * strnatcasecmp($a['SCHEMA_TABLES'], $b['SCHEMA_TABLES'])
148-
$compare = $cfg['NaturalOrder']
149-
? strnatcasecmp($a[$sortBy], $b[$sortBy])
150-
: strcasecmp($a[$sortBy], $b[$sortBy]);
148+
$compare = $cfg['NaturalOrder'] ? strnatcasecmp(
149+
(string) $a[$sortBy],
150+
(string) $b[$sortBy]
151+
) : strcasecmp(
152+
(string) $a[$sortBy],
153+
(string) $b[$sortBy]
154+
);
151155

152156
return ($sortOrder === 'ASC' ? 1 : -1) * $compare;
153157
}

psalm-baseline.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11705,12 +11705,6 @@
1170511705
</MixedArgumentTypeCoercion>
1170611706
</file>
1170711707
<file src="libraries/classes/Query/Utilities.php">
11708-
<MixedArgument occurrences="4">
11709-
<code>$a[$sortBy]</code>
11710-
<code>$a[$sortBy]</code>
11711-
<code>$b[$sortBy]</code>
11712-
<code>$b[$sortBy]</code>
11713-
</MixedArgument>
1171411708
<MixedArrayAssignment occurrences="1">
1171511709
<code>$_SESSION['debug']['queries']</code>
1171611710
</MixedArrayAssignment>

test/classes/DatabaseInterfaceTest.php

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
use PhpMyAdmin\ConfigStorage\Relation;
88
use PhpMyAdmin\Database\DatabaseList;
9+
use PhpMyAdmin\DatabaseInterface;
910
use PhpMyAdmin\Dbal\ResultInterface;
1011
use PhpMyAdmin\Query\Utilities;
1112
use PhpMyAdmin\SystemDatabase;
1213
use PhpMyAdmin\Utils\SessionCache;
14+
use stdClass;
1315

1416
/**
1517
* @covers \PhpMyAdmin\DatabaseInterface
@@ -501,4 +503,203 @@ public function testQueryAsControlUser(): void
501503
);
502504
$this->assertFalse($this->dbi->tryQueryAsControlUser('Invalid query'));
503505
}
506+
507+
public function testGetDatabasesFullDisabledISAndSortIntColumn(): void
508+
{
509+
parent::setGlobalDbi();
510+
511+
$GLOBALS['db'] = '';
512+
$GLOBALS['table'] = '';
513+
$GLOBALS['server'] = 1;
514+
$GLOBALS['cfg']['Server']['DisableIS'] = true;
515+
$GLOBALS['cfg']['NaturalOrder'] = true;
516+
$GLOBALS['dblist'] = new stdClass();
517+
$GLOBALS['dblist']->databases = [
518+
'db1',
519+
'db2',
520+
];
521+
$this->dummyDbi->removeDefaultResults();
522+
$this->dummyDbi->addResult(
523+
'SELECT @@collation_database',
524+
[
525+
['utf8_general_ci'],
526+
],
527+
['@@collation_database']
528+
);
529+
$this->dummyDbi->addResult(
530+
'SELECT @@collation_database',
531+
[
532+
['utf8_general_ci'],
533+
],
534+
['@@collation_database']
535+
);
536+
$this->dummyDbi->addResult(
537+
'SHOW TABLE STATUS FROM `db1`;',
538+
[
539+
[
540+
'pma__bookmark',
541+
'InnoDB',
542+
10,
543+
'Dynamic',
544+
0,
545+
0,
546+
16384,
547+
0,
548+
0,
549+
0,
550+
1,
551+
'2021-08-27 14:11:52',
552+
null,
553+
null,
554+
'utf8_bin',
555+
null,
556+
'Bookmarks',
557+
],
558+
[
559+
'pma__central_columns',
560+
'InnoDB',
561+
10,
562+
'Dynamic',
563+
0,
564+
0,
565+
16384,
566+
0,
567+
0,
568+
0,
569+
null,
570+
'2021-08-27 14:11:52',
571+
null,
572+
null,
573+
'utf8_bin',
574+
null,
575+
'Central list of columns',
576+
],
577+
],
578+
[
579+
'Name',
580+
'Engine',
581+
'Version',
582+
'Row_format',
583+
'Rows',
584+
'Avg_row_length',
585+
'Data_length',
586+
'Max_data_length',
587+
'Index_length',
588+
'Data_free',
589+
'Auto_increment',
590+
'Create_time',
591+
'Update_time',
592+
'Check_time',
593+
'Collation',
594+
'Checksum',
595+
'Create_options',
596+
'Comment',
597+
]
598+
);
599+
600+
$this->dummyDbi->addResult(
601+
'SHOW TABLE STATUS FROM `db2`;',
602+
[
603+
[
604+
'pma__bookmark',
605+
'InnoDB',
606+
10,
607+
'Dynamic',
608+
0,
609+
0,
610+
16324,
611+
0,
612+
0,
613+
0,
614+
1,
615+
'2021-08-27 14:11:52',
616+
null,
617+
null,
618+
'utf8_bin',
619+
null,
620+
'Bookmarks',
621+
],
622+
[
623+
'pma__central_columns',
624+
'InnoDB',
625+
10,
626+
'Dynamic',
627+
0,
628+
0,
629+
14384,
630+
0,
631+
0,
632+
0,
633+
null,
634+
'2021-08-27 14:11:52',
635+
null,
636+
null,
637+
'utf8_bin',
638+
null,
639+
'Central list of columns',
640+
],
641+
],
642+
[
643+
'Name',
644+
'Engine',
645+
'Version',
646+
'Row_format',
647+
'Rows',
648+
'Avg_row_length',
649+
'Data_length',
650+
'Max_data_length',
651+
'Index_length',
652+
'Data_free',
653+
'Auto_increment',
654+
'Create_time',
655+
'Update_time',
656+
'Check_time',
657+
'Collation',
658+
'Checksum',
659+
'Create_options',
660+
'Comment',
661+
]
662+
);
663+
$this->dummyDbi->addSelectDb('');
664+
$this->dummyDbi->addSelectDb('');
665+
$this->dummyDbi->addSelectDb('db1');
666+
$this->dummyDbi->addSelectDb('db2');
667+
668+
$databaseList = $this->dbi->getDatabasesFull(
669+
null,
670+
true,
671+
DatabaseInterface::CONNECT_USER,
672+
'SCHEMA_DATA_LENGTH',
673+
'ASC',
674+
0,
675+
100
676+
);
677+
678+
$this->assertSame([
679+
[
680+
'SCHEMA_NAME' => 'db2',
681+
'DEFAULT_COLLATION_NAME' => 'utf8_general_ci',
682+
'SCHEMA_TABLES' => 2,
683+
'SCHEMA_TABLE_ROWS' => 0,
684+
'SCHEMA_DATA_LENGTH' => 30708,
685+
'SCHEMA_MAX_DATA_LENGTH' => 0,
686+
'SCHEMA_INDEX_LENGTH' => 0,
687+
'SCHEMA_LENGTH' => 30708,
688+
'SCHEMA_DATA_FREE' => 0,
689+
],
690+
[
691+
'SCHEMA_NAME' => 'db1',
692+
'DEFAULT_COLLATION_NAME' => 'utf8_general_ci',
693+
'SCHEMA_TABLES' => 2,
694+
'SCHEMA_TABLE_ROWS' => 0,
695+
'SCHEMA_DATA_LENGTH' => 32768,
696+
'SCHEMA_MAX_DATA_LENGTH' => 0,
697+
'SCHEMA_INDEX_LENGTH' => 0,
698+
'SCHEMA_LENGTH' => 32768,
699+
'SCHEMA_DATA_FREE' => 0,
700+
],
701+
], $databaseList);
702+
703+
$this->assertAllQueriesConsumed();
704+
}
504705
}

test/classes/Stubs/DbiDummy.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,17 @@
1919

2020
use function addslashes;
2121
use function count;
22-
use function debug_backtrace;
23-
use function fwrite;
2422
use function is_array;
2523
use function is_bool;
2624
use function is_int;
27-
use function json_encode;
2825
use function preg_replace;
2926
use function str_replace;
3027
use function trim;
3128

32-
use const DEBUG_BACKTRACE_IGNORE_ARGS;
33-
use const JSON_PRETTY_PRINT;
34-
use const JSON_UNESCAPED_SLASHES;
3529
use const MYSQLI_TYPE_BLOB;
3630
use const MYSQLI_TYPE_DATETIME;
3731
use const MYSQLI_TYPE_DECIMAL;
3832
use const MYSQLI_TYPE_STRING;
39-
use const PHP_EOL;
40-
use const STDERR;
4133

4234
// phpcs:disable Generic.Files.LineLength.TooLong
4335

@@ -140,13 +132,7 @@ public function selectDb($databaseName, $link): bool
140132
return true;
141133
}
142134

143-
fwrite(STDERR, 'Non expected select of database: ' . $databaseName . PHP_EOL);
144-
fwrite(STDERR, 'Trace: ' . json_encode(
145-
debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5),
146-
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
147-
) . PHP_EOL);
148-
149-
return false;
135+
Assert::markTestIncomplete('Non expected select of database: ' . $databaseName);
150136
}
151137

152138
public function hasUnUsedErrors(): bool
@@ -507,7 +493,7 @@ public function addSelectDb(string $databaseName): void
507493
* @param array|bool $result Expected result
508494
* @param string[] $columns The result columns
509495
* @param object[] $metadata The result metadata
510-
* @phpstan-param (int[]|string[]|array{string: string}|null[])[]|bool|bool[] $result
496+
* @phpstan-param array<int, array<int, array{string: string}|bool|int|string|null>|bool>|bool $result
511497
*/
512498
public function addResult(string $query, $result, array $columns = [], array $metadata = []): void
513499
{

0 commit comments

Comments
 (0)