From 66aac18bad2d857e1df0b33058c2cc286ba859a5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 2 Jul 2024 12:13:14 +0200 Subject: [PATCH] fix(db)!: `OCP\DB\IPreparedStatement::bindParam()` is deprecated and calls `bindValue()` internally Signed-off-by: Joas Schilling --- lib/private/DB/PreparedStatement.php | 10 ++++++++-- lib/public/DB/IPreparedStatement.php | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/private/DB/PreparedStatement.php b/lib/private/DB/PreparedStatement.php index 00a32a629f7..9f6872f1d2b 100644 --- a/lib/private/DB/PreparedStatement.php +++ b/lib/private/DB/PreparedStatement.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Statement; use OCP\DB\IPreparedStatement; use OCP\DB\IResult; +use OCP\DB\QueryBuilder\IQueryBuilder; use PDO; /** @@ -58,11 +59,16 @@ class PreparedStatement implements IPreparedStatement { } public function bindValue($param, $value, $type = ParameterType::STRING): bool { - return $this->statement->bindValue($param, $value, $type); + $this->statement->bindValue($param, $value, $type); + return true; } public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool { - return $this->statement->bindParam($param, $variable, $type, $length); + if ($type !== IQueryBuilder::PARAM_STR) { + \OC::$server->getLogger()->warning('PreparedStatement::bindParam() is no longer supported. Use bindValue() instead.', ['exception' => new \BadMethodCallException('bindParam() is no longer supported')]); + } + $this->bindValue($param, $variable, $type); + return true; } public function execute($params = null): IResult { diff --git a/lib/public/DB/IPreparedStatement.php b/lib/public/DB/IPreparedStatement.php index 887451a1caf..d77f677b719 100644 --- a/lib/public/DB/IPreparedStatement.php +++ b/lib/public/DB/IPreparedStatement.php @@ -93,6 +93,7 @@ interface IPreparedStatement { * @throws Exception * * @since 21.0.0 + * @deprecated 30.0.0 Use {@see self::bindValue()} instead */ public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool;