Skip to content

Commit

Permalink
Merge pull request #4030 from morozov/remove-deprecations
Browse files Browse the repository at this point in the history
Backport removal of some deprecated APIs
  • Loading branch information
greg0ire authored May 27, 2020
2 parents 179ab95 + a48cad1 commit 67944fc
Show file tree
Hide file tree
Showing 21 changed files with 18 additions and 525 deletions.
12 changes: 12 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Upgrade to 3.0

## BC BREAK: Dropped handling of one-based numeric arrays of parameters in `Statement::execute()`

The statement implementations no longer detect whether `$params` is a zero- or one-based array. A zero-based numeric array is expected.

## BC BREAK `Statement::project()` has been removed

- The `Statement::project()` method has been removed. Use `::executeQuery()` and fetch the data from the statement using one of the `Statement::fetch*()` methods instead.

## BC BREAK `::errorCode()` and `::errorInfo()` removed from `Connection` and `Statement` APIs

The error information is available in `DriverException` thrown in case of an error.

## BC BREAK: Dropped support for `FetchMode::CUSTOM_OBJECT` and `::STANDARD_OBJECT`

Instead of fetching an object, fetch an array and map it to an object of the desired class.
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ parameters:
- '~^Method Doctrine\\DBAL\\Schema\\ForeignKeyConstraint::onEvent\(\) should return string\|null but returns false\.\z~'
- '~^Method Doctrine\\DBAL\\Schema\\(Oracle|PostgreSql|SQLServer)SchemaManager::_getPortableTableDefinition\(\) should return array but returns string\.\z~'
- '~^Method Doctrine\\DBAL\\Driver\\OCI8\\OCI8Connection::lastInsertId\(\) should return string but returns (int|false)\.\z~'
- '~^Method Doctrine\\DBAL\\Driver\\SQLSrv\\SQLSrvConnection::errorCode\(\) should return string\|null but returns false\.\z~'

# https://bugs.php.net/bug.php?id=78126
- '~^Call to an undefined method PDO::sqliteCreateFunction\(\)\.\z~'
Expand Down
50 changes: 0 additions & 50 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1187,34 +1187,6 @@ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qc
return $stmt;
}

/**
* Executes an, optionally parametrized, SQL query and returns the result,
* applying a given projection/transformation function on each row of the result.
*
* @deprecated
*
* @param string $query The SQL query to execute.
* @param mixed[] $params The parameters, if any.
* @param Closure $function The transformation function that is applied on each row.
* The function receives a single parameter, an array, that
* represents a row of the result set.
*
* @return mixed[] The projected result of the query.
*/
public function project($query, array $params, Closure $function)
{
$result = [];
$stmt = $this->executeQuery($query, $params);

while ($row = $stmt->fetch()) {
$result[] = $function($row);
}

$stmt->closeCursor();

return $result;
}

public function query(string $sql) : ResultStatement
{
$connection = $this->getWrappedConnection();
Expand Down Expand Up @@ -1320,28 +1292,6 @@ public function getTransactionNestingLevel()
return $this->transactionNestingLevel;
}

/**
* Fetches the SQLSTATE associated with the last database operation.
*
* @deprecated The error information is available via exceptions.
*
* @return string|null The last error code.
*/
public function errorCode()
{
return $this->getWrappedConnection()->errorCode();
}

/**
* {@inheritDoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorInfo()
{
return $this->getWrappedConnection()->errorInfo();
}

/**
* Returns the ID of the last inserted row, or the last value from a sequence object,
* depending on the underlying driver.
Expand Down
18 changes: 0 additions & 18 deletions src/Driver/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,4 @@ public function commit();
* @return bool TRUE on success or FALSE on failure.
*/
public function rollBack();

/**
* Returns the error code associated with the last operation on the database handle.
*
* @deprecated The error information is available via exceptions.
*
* @return string|null The error code, or null if no operation has been run on the database handle.
*/
public function errorCode();

/**
* Returns extended error information associated with the last operation on the database handle.
*
* @deprecated The error information is available via exceptions.
*
* @return mixed[]
*/
public function errorInfo();
}
24 changes: 0 additions & 24 deletions src/Driver/IBMDB2/DB2Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use function assert;
use function db2_autocommit;
use function db2_commit;
use function db2_conn_error;
use function db2_conn_errormsg;
use function db2_connect;
use function db2_escape_string;
Expand Down Expand Up @@ -166,27 +165,4 @@ public function rollBack()

return $result;
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorCode()
{
return db2_conn_error($this->conn);
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorInfo()
{
return [
0 => db2_conn_errormsg($this->conn),
1 => $this->errorCode(),
];
}
}
24 changes: 0 additions & 24 deletions src/Driver/IBMDB2/DB2Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use function db2_free_result;
use function db2_num_fields;
use function db2_num_rows;
use function db2_stmt_error;
use function db2_stmt_errormsg;
use function error_get_last;
use function fclose;
Expand Down Expand Up @@ -154,29 +153,6 @@ public function columnCount()
return 0;
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorCode()
{
return db2_stmt_error();
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorInfo()
{
return [
db2_stmt_errormsg(),
db2_stmt_error(),
];
}

/**
* {@inheritdoc}
*/
Expand Down
20 changes: 0 additions & 20 deletions src/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,26 +193,6 @@ public function rollBack()
return $this->conn->rollback();
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorCode()
{
return $this->conn->errno;
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorInfo()
{
return $this->conn->error;
}

/**
* Apply the driver options to the connection.
*
Expand Down
18 changes: 0 additions & 18 deletions src/Driver/Mysqli/MysqliStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,24 +463,6 @@ public function fetchAllAssociative() : array
return FetchUtils::fetchAllAssociative($this);
}

/**
* {@inheritdoc}
*/
public function errorCode()
{
return $this->_stmt->errno;
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorInfo()
{
return $this->_stmt->error;
}

/**
* {@inheritdoc}
*/
Expand Down
35 changes: 2 additions & 33 deletions src/Driver/OCI8/OCI8Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function beginTransaction()
public function commit()
{
if (! oci_commit($this->dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo());
throw OCI8Exception::fromErrorInfo(oci_error($this->dbh));
}

$this->executeMode = OCI_COMMIT_ON_SUCCESS;
Expand All @@ -195,42 +195,11 @@ public function commit()
public function rollBack()
{
if (! oci_rollback($this->dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo());
throw OCI8Exception::fromErrorInfo(oci_error($this->dbh));
}

$this->executeMode = OCI_COMMIT_ON_SUCCESS;

return true;
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorCode()
{
$error = oci_error($this->dbh);
if ($error !== false) {
$error = $error['code'];
}

return $error;
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorInfo()
{
$error = oci_error($this->dbh);

if ($error === false) {
return [];
}

return $error;
}
}
37 changes: 2 additions & 35 deletions src/Driver/OCI8/OCI8Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Doctrine\DBAL\ParameterType;
use InvalidArgumentException;
use IteratorAggregate;
use function array_key_exists;
use function assert;
use function count;
use function implode;
Expand Down Expand Up @@ -356,46 +355,14 @@ public function columnCount()
return 0;
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorCode()
{
$error = oci_error($this->_sth);
if ($error !== false) {
$error = $error['code'];
}

return $error;
}

/**
* {@inheritdoc}
*
* @deprecated The error information is available via exceptions.
*/
public function errorInfo()
{
$error = oci_error($this->_sth);

if ($error === false) {
return [];
}

return $error;
}

/**
* {@inheritdoc}
*/
public function execute($params = null)
{
if ($params !== null) {
$hasZeroIndex = array_key_exists(0, $params);
foreach ($params as $key => $val) {
if ($hasZeroIndex && is_int($key)) {
if (is_int($key)) {
$this->bindValue($key + 1, $val);
} else {
$this->bindValue($key, $val);
Expand All @@ -405,7 +372,7 @@ public function execute($params = null)

$ret = @oci_execute($this->_sth, $this->_conn->getExecuteMode());
if (! $ret) {
throw OCI8Exception::fromErrorInfo($this->errorInfo());
throw OCI8Exception::fromErrorInfo(oci_error($this->_sth));
}

$this->result = true;
Expand Down
16 changes: 0 additions & 16 deletions src/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,6 @@ public function rollBack()
return $this->connection->rollBack();
}

/**
* {@inheritDoc}
*/
public function errorCode()
{
return $this->connection->errorCode();
}

/**
* {@inheritDoc}
*/
public function errorInfo()
{
return $this->connection->errorInfo();
}

public function getWrappedConnection() : PDO
{
return $this->connection;
Expand Down
Loading

0 comments on commit 67944fc

Please sign in to comment.