Skip to content

Commit

Permalink
Merge branch 'QA_5_2'
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
  • Loading branch information
MauricioFauth committed Nov 12, 2023
2 parents 083fdd8 + 445301c commit 5315055
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ phpMyAdmin - ChangeLog
- issue #17381 Fixed JS errors when editing indexes on create table
- issue #14402 Fix the PRIMARY label still shown when using two columns for a PK on create table
- issue #17347 Fixed JS errors when changing index settings on create table
- issue Fix BETWEEN search does not validate input because of spaces
- issue Fix JS number validation does not validate when the input is empty or emptied

5.2.1 (2023-02-07)
- issue #17522 Fix case where the routes cache file is invalid
Expand Down
4 changes: 2 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2626,12 +2626,12 @@ parameters:
path: src/Controllers/Database/Structure/EmptyTableController.php

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

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

Expand Down
1 change: 0 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,6 @@
</InvalidArgument>
<PossiblyInvalidArgument>
<code>$selected</code>
<code>$selected[$i]</code>
</PossiblyInvalidArgument>
<PossiblyUnusedMethod>
<code>__construct</code>
Expand Down
10 changes: 9 additions & 1 deletion resources/js/src/table/change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ function verifyAfterSearchFieldChange (index, searchFormId) {
// BETWEEN and NOT BETWEEN
// See all possible syntaxes in tests of https://regexr.com/7h1eq
jQuery.validator.addMethod('validationFunctionForMultipleInt', function (value) {
return value.match(/^(((0x[0-9a-f]+)|([+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)(e[+-]?[0-9]+)?))(,|$))+$/i) !== null;
if (value === '') {
return true;
}

return value.replace(/ /g,'').match(/^(((0x[0-9a-f]+)|([+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)(e[+-]?[0-9]+)?))(,|$))+$/i) !== null;
},
window.Messages.strEnterValidNumber
);
Expand All @@ -200,6 +204,10 @@ function verifyAfterSearchFieldChange (index, searchFormId) {
// validator method for INTs
// See all possible syntaxes in tests of https://regexr.com/7h1ci
jQuery.validator.addMethod('validationFunctionForInt', function (value) {
if (value === '') {
return true;
}

return value.match(/^(0x[0-9a-f]+$)|([+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)(e[+-]?[0-9]+)?)$/i) !== null;
},
window.Messages.strEnterValidNumber
Expand Down
6 changes: 6 additions & 0 deletions src/Controllers/Database/Structure/EmptyTableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
use PhpMyAdmin\Operations;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Sql;
use PhpMyAdmin\Table;
use PhpMyAdmin\Template;
use PhpMyAdmin\Transformations;
use PhpMyAdmin\Util;
use PhpMyAdmin\Utils\ForeignKey;

use function __;
use function count;
use function is_string;

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

for ($i = 0; $i < $selectedCount; $i++) {
if (! is_string($selected[$i]) || Table::get($selected[$i], $GLOBALS['db'], $this->dbi)->isView()) {
continue;
}

$aQuery = 'TRUNCATE ';
$aQuery .= Util::backquote($selected[$i]);

Expand Down
6 changes: 6 additions & 0 deletions src/Partitioning/Maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Table;
use PhpMyAdmin\Util;

use function __;
use function sprintf;

final class Maintenance
Expand Down Expand Up @@ -136,6 +138,10 @@ public function repair(DatabaseName $db, TableName $table, string $partition): a
*/
public function truncate(DatabaseName $db, TableName $table, string $partition): array
{
if (Table::get($table->getName(), $db->getName(), $this->dbi)->isView()) {
return [false, __('This table is a view, it can not be truncated.')];
}

$query = sprintf(
'ALTER TABLE %s TRUNCATE PARTITION %s;',
Util::backquote($table->getName()),
Expand Down

0 comments on commit 5315055

Please sign in to comment.