From a3db5915d8c2b4665ab236ca584e6fa1a8561005 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 9 Jan 2024 03:28:59 +0100 Subject: [PATCH] Remove escapeString from Bookmark This is changing the behaviour. The variable is no longer escaped. This can be documented for users to be aware, however, the users will most likely notice the change. The input now needs to be properly formatted part of SQL query. Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 9 ++------- psalm-baseline.xml | 9 +++++---- src/Bookmarks/Bookmark.php | 5 +---- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0069e694a4..212724343a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -121,13 +121,8 @@ parameters: path: src/Advisory/Advisor.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" - count: 1 - path: src/Bookmarks/Bookmark.php - - - - message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:escapeString\\(\\) expects string, mixed given\\.$#" - count: 1 + message: "#^Parameter \\#2 \\$replace of function str_replace expects array\\|string, mixed given\\.$#" + count: 2 path: src/Bookmarks/Bookmark.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4cb89dd4af..120c7ae38d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -40,12 +40,13 @@ - - escapeString - - $variables[$i] + $var + $var + + $var + getDatabase diff --git a/src/Bookmarks/Bookmark.php b/src/Bookmarks/Bookmark.php index bc45fd1501..3e0c5fda69 100644 --- a/src/Bookmarks/Bookmark.php +++ b/src/Bookmarks/Bookmark.php @@ -137,10 +137,7 @@ class Bookmark // replace variable placeholders with values $numberOfVariables = $this->getVariableCount(); for ($i = 1; $i <= $numberOfVariables; $i++) { - $var = ''; - if (! empty($variables[$i])) { - $var = $this->dbi->escapeString($variables[$i]); - } + $var = $variables[$i] ?? ''; $query = str_replace('[VARIABLE' . $i . ']', $var, $query); // backward compatibility