fix(db)!: OCP\DB\IPreparedStatement::bindParam() is deprecated and calls bindValue() internally

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2024-07-02 12:13:14 +02:00
parent 715656927c
commit 66aac18bad
No known key found for this signature in database
GPG key ID: 74434EFE0D2E2205
2 changed files with 9 additions and 2 deletions

View file

@ -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 {

View file

@ -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;