From b7b62f5fbcf63bf1e6a86cc72d783178f548f526 Mon Sep 17 00:00:00 2001 From: Jan Jakes Date: Wed, 28 Aug 2024 14:47:05 +0200 Subject: [PATCH] Remove confusing comments in WPDB driver On the low lever of the WPDB driver, we're indeed executing an unknown query, and we can't say that they are by themeselves fully safe. It's higher levels of abstraction in Doctrine that aim to prevent us from generating unsafe querires. [MAILPOET-6150] --- mailpoet/lib/Doctrine/WPDB/Connection.php | 2 +- mailpoet/lib/Doctrine/WPDB/Statement.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mailpoet/lib/Doctrine/WPDB/Connection.php b/mailpoet/lib/Doctrine/WPDB/Connection.php index c38a7b2865..3554b9d64b 100644 --- a/mailpoet/lib/Doctrine/WPDB/Connection.php +++ b/mailpoet/lib/Doctrine/WPDB/Connection.php @@ -109,7 +109,7 @@ class Connection implements ServerInfoAwareConnection { private function runQuery(string $sql) { global $wpdb; try { - $value = $wpdb->query($sql); // phpcs:ignore WordPressDotOrg.sniffs.DirectDB.UnescapedDBParameter,WordPress.DB.PreparedSQL.NotPrepared -- The variable is prepared but the sniff recognize only a string + $value = $wpdb->query($sql); // phpcs:ignore WordPressDotOrg.sniffs.DirectDB.UnescapedDBParameter,WordPress.DB.PreparedSQL.NotPrepared } catch (Throwable $e) { if ($e instanceof PDOException) { throw new QueryException($e->getMessage(), $e->errorInfo[0] ?? null, $e->errorInfo[1] ?? 0); diff --git a/mailpoet/lib/Doctrine/WPDB/Statement.php b/mailpoet/lib/Doctrine/WPDB/Statement.php index b2ac02ec69..52a74722be 100644 --- a/mailpoet/lib/Doctrine/WPDB/Statement.php +++ b/mailpoet/lib/Doctrine/WPDB/Statement.php @@ -62,7 +62,9 @@ class Statement implements StatementInterface { $values = $visitor->getValues(); global $wpdb; - $query = count($values) > 0 ? $wpdb->prepare($sql, $values) : $sql; // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- The prepare method is used here to escape the values + $query = count($values) > 0 + ? $wpdb->prepare($sql, $values) // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared + : $sql; return $this->connection->query($query); } }