Skip to content

Commit

Permalink
Fix #17538 Index Rename Button generated incorrect sql
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela committed Dec 27, 2023
1 parent 98ff89e commit 7652f01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public function __invoke(): void
if (isset($_POST['index'])) {
if (is_array($_POST['index'])) {
// coming already from form
$index = new Index($_POST['index']);
$oldIndex = is_array($_POST['old_index']) ? $_POST['old_index']['Key_name'] : $_POST['old_index'];
$index = clone $this->dbi->getTable($this->db, $this->table)->getIndex($oldIndex);
$index->setName($_POST['index']['Key_name']);
} else {
$index = $this->dbi->getTable($this->db, $this->table)->getIndex($_POST['index']);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,7 @@ public function getSqlQueryForIndexCreateOrEdit($index, &$error)
' ADD %s ',
$index->getChoice()
);
if ($index->getName()) {
if ($index->getName() !== '') {
$sqlQuery .= Util::backquote($index->getName());
}

Expand Down
8 changes: 8 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3363,6 +3363,14 @@
<MixedArgumentTypeCoercion occurrences="1">
<code>$urlParams</code>
</MixedArgumentTypeCoercion>
<PossiblyInvalidArgument occurrences="2">
<code>$_POST['index']['Key_name']</code>
<code>$oldIndex</code>
</PossiblyInvalidArgument>
<PossiblyInvalidCast occurrences="2">
<code>$_POST['index']['Key_name']</code>
<code>$oldIndex</code>
</PossiblyInvalidCast>
</file>
<file src="libraries/classes/Controllers/Table/IndexesController.php">
<MixedArgument occurrences="2">
Expand Down

0 comments on commit 7652f01

Please sign in to comment.