Skip to content

Commit 5315055

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2 parents 083fdd8 + 445301c commit 5315055

6 files changed

Lines changed: 25 additions & 4 deletions

File tree

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ phpMyAdmin - ChangeLog
7272
- issue #17381 Fixed JS errors when editing indexes on create table
7373
- issue #14402 Fix the PRIMARY label still shown when using two columns for a PK on create table
7474
- issue #17347 Fixed JS errors when changing index settings on create table
75+
- issue Fix BETWEEN search does not validate input because of spaces
76+
- issue Fix JS number validation does not validate when the input is empty or emptied
7577

7678
5.2.1 (2023-02-07)
7779
- issue #17522 Fix case where the routes cache file is invalid

phpstan-baseline.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,12 +2626,12 @@ parameters:
26262626
path: src/Controllers/Database/Structure/EmptyTableController.php
26272627

26282628
-
2629-
message: "#^Parameter \\#1 \\$identifier of static method PhpMyAdmin\\\\Util\\:\\:backquote\\(\\) expects string\\|Stringable\\|null, mixed given\\.$#"
2629+
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
26302630
count: 1
26312631
path: src/Controllers/Database/Structure/EmptyTableController.php
26322632

26332633
-
2634-
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
2634+
message: "#^Parameter \\#2 \\$dbName of static method PhpMyAdmin\\\\Table\\:\\:get\\(\\) expects string, mixed given\\.$#"
26352635
count: 1
26362636
path: src/Controllers/Database/Structure/EmptyTableController.php
26372637

psalm-baseline.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,6 @@
15411541
</InvalidArgument>
15421542
<PossiblyInvalidArgument>
15431543
<code>$selected</code>
1544-
<code>$selected[$i]</code>
15451544
</PossiblyInvalidArgument>
15461545
<PossiblyUnusedMethod>
15471546
<code>__construct</code>

resources/js/src/table/change.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ function verifyAfterSearchFieldChange (index, searchFormId) {
190190
// BETWEEN and NOT BETWEEN
191191
// See all possible syntaxes in tests of https://regexr.com/7h1eq
192192
jQuery.validator.addMethod('validationFunctionForMultipleInt', function (value) {
193-
return value.match(/^(((0x[0-9a-f]+)|([+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)(e[+-]?[0-9]+)?))(,|$))+$/i) !== null;
193+
if (value === '') {
194+
return true;
195+
}
196+
197+
return value.replace(/ /g,'').match(/^(((0x[0-9a-f]+)|([+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)(e[+-]?[0-9]+)?))(,|$))+$/i) !== null;
194198
},
195199
window.Messages.strEnterValidNumber
196200
);
@@ -200,6 +204,10 @@ function verifyAfterSearchFieldChange (index, searchFormId) {
200204
// validator method for INTs
201205
// See all possible syntaxes in tests of https://regexr.com/7h1ci
202206
jQuery.validator.addMethod('validationFunctionForInt', function (value) {
207+
if (value === '') {
208+
return true;
209+
}
210+
203211
return value.match(/^(0x[0-9a-f]+$)|([+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)(e[+-]?[0-9]+)?)$/i) !== null;
204212
},
205213
window.Messages.strEnterValidNumber

src/Controllers/Database/Structure/EmptyTableController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
use PhpMyAdmin\Operations;
1717
use PhpMyAdmin\ResponseRenderer;
1818
use PhpMyAdmin\Sql;
19+
use PhpMyAdmin\Table;
1920
use PhpMyAdmin\Template;
2021
use PhpMyAdmin\Transformations;
2122
use PhpMyAdmin\Util;
2223
use PhpMyAdmin\Utils\ForeignKey;
2324

2425
use function __;
2526
use function count;
27+
use function is_string;
2628

2729
final class EmptyTableController extends AbstractController
2830
{
@@ -57,6 +59,10 @@ public function __invoke(ServerRequest $request): void
5759
$selectedCount = count($selected);
5860

5961
for ($i = 0; $i < $selectedCount; $i++) {
62+
if (! is_string($selected[$i]) || Table::get($selected[$i], $GLOBALS['db'], $this->dbi)->isView()) {
63+
continue;
64+
}
65+
6066
$aQuery = 'TRUNCATE ';
6167
$aQuery .= Util::backquote($selected[$i]);
6268

src/Partitioning/Maintenance.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
use PhpMyAdmin\DatabaseInterface;
88
use PhpMyAdmin\Identifiers\DatabaseName;
99
use PhpMyAdmin\Identifiers\TableName;
10+
use PhpMyAdmin\Table;
1011
use PhpMyAdmin\Util;
1112

13+
use function __;
1214
use function sprintf;
1315

1416
final class Maintenance
@@ -136,6 +138,10 @@ public function repair(DatabaseName $db, TableName $table, string $partition): a
136138
*/
137139
public function truncate(DatabaseName $db, TableName $table, string $partition): array
138140
{
141+
if (Table::get($table->getName(), $db->getName(), $this->dbi)->isView()) {
142+
return [false, __('This table is a view, it can not be truncated.')];
143+
}
144+
139145
$query = sprintf(
140146
'ALTER TABLE %s TRUNCATE PARTITION %s;',
141147
Util::backquote($table->getName()),

0 commit comments

Comments
 (0)