Skip to content

Merge 4.3.x up into 5.0.x #6628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 30 additions & 51 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ jobs:
os:
- "ubuntu-22.04"
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
dependencies:
- "highest"
extension:
Expand Down Expand Up @@ -101,15 +99,15 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
oracle-version:
- "18"
- "21"
- "23"
include:
- php-version: "8.4"
- php-version: "8.1"
oracle-version: "23"
- php-version: "8.5"
oracle-version: "23"

services:
Expand Down Expand Up @@ -161,15 +159,15 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
oracle-version:
- "18"
- "21"
- "23"
include:
- php-version: "8.4"
- php-version: "8.1"
oracle-version: "23"
- php-version: "8.5"
oracle-version: "23"

services:
Expand Down Expand Up @@ -221,7 +219,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.4"
postgres-version:
- "12"
- "16"
Expand All @@ -230,16 +228,16 @@ jobs:
- "pgsql"
- "pdo_pgsql"
include:
- php-version: "8.2"
- php-version: "8.1"
postgres-version: "17"
extension: "pgsql"
- php-version: "8.3"
- php-version: "8.1"
postgres-version: "17"
extension: "pgsql"
- php-version: "8.4"
extension: "pdo_pgsql"
- php-version: "8.5"
postgres-version: "17"
extension: "pgsql"
- php-version: "8.4"
- php-version: "8.5"
postgres-version: "17"
extension: "pdo_pgsql"

Expand Down Expand Up @@ -291,30 +289,27 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.4"
mariadb-version:
# keep in sync with https://mariadb.org/about/#maintenance-policy
- "10.5" # Oldest version supported by DBAL, LTS (Jun 2025)
- "10.6" # LTS (Jul 2026)
- "10.11" # LTS (Feb 2028)
- "11.1" # STS (Aug 2024)
- "11.2" # STS (Nov 2024)
- "11.3" # STS (Feb 2025)
- "10.5" # Oldest version supported by DBAL, LTS (Jun 2025) We have code specific to 10.5.2-10.6.0
- "10.6" # LTS (Jul 2026) We have code specific to 10.6.0-10.10.0
- "10.11" # LTS (Feb 2028) We have code specific to ^10.10
- "11.4" # LTS (May 2029)
extension:
- "mysqli"
- "pdo_mysql"
include:
- php-version: "8.2"
- php-version: "8.1"
mariadb-version: "11.4"
extension: "mysqli"
- php-version: "8.3"
- php-version: "8.1"
mariadb-version: "11.4"
extension: "pdo_mysql"
- php-version: "8.4"
- php-version: "8.5"
mariadb-version: "11.4"
extension: "mysqli"
- php-version: "8.4"
- php-version: "8.5"
mariadb-version: "11.4"
extension: "pdo_mysql"

Expand Down Expand Up @@ -367,7 +362,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.3"
- "8.4"
mysql-version:
- "8.0"
- "9.1"
Expand All @@ -379,29 +374,15 @@ jobs:
include:
- config-file-suffix: "-tls"
php-version: "8.1"
mysql-version: "8.0"
extension: "mysqli"
- php-version: "8.1"
mysql-version: "8.0"
mysql-version: "9.1"
extension: "mysqli"
- php-version: "8.1"
mysql-version: "8.0"
extension: "pdo_mysql"
# Workaround for https://bugs.mysql.com/114876
- php-version: "8.3"
mysql-version: "8.4"
mysql-version: "9.1"
extension: "mysqli"
custom-entrypoint: >-
--entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
- php-version: "8.3"
mysql-version: "8.4"
extension: "pdo_mysql"
custom-entrypoint: >-
--entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON"
- php-version: "8.4"
- php-version: "8.5"
mysql-version: "9.1"
extension: "mysqli"
- php-version: "8.4"
- php-version: "8.5"
mysql-version: "9.1"
extension: "pdo_mysql"

Expand Down Expand Up @@ -459,9 +440,8 @@ jobs:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
extension:
- "sqlsrv"
- "pdo_sqlsrv"
Expand Down Expand Up @@ -527,9 +507,8 @@ jobs:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"

services:
ibm_db2:
Expand Down
1 change: 1 addition & 0 deletions docs/en/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ pdo_oci / oci8
- ``driverOptions`` (array):
- ``exclusive`` (boolean): Once specified for an ``oci8`` connection, forces the driver to always establish
a new connection instead of reusing an existing one from the connection pool.
- ``protocol`` (string): The protocol used to connect to Oracle (default TCP, Autonomous tends to be TCPS). See `docs.oracle.com/en/enterprise-manager/cloud-control/enterprise-manager-cloud-control/13.4/emsec/secured-communication-tcps-access-databases.html <https://docs.oracle.com/en/enterprise-manager/cloud-control/enterprise-manager-cloud-control/13.4/emsec/secured-communication-tcps-access-databases.html>`_.

pdo_sqlsrv / sqlsrv
^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/AbstractOracleDriver/EasyConnectString.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function fromConnectionParameters(array $params): self
return self::fromArray([
'DESCRIPTION' => [
'ADDRESS' => [
'PROTOCOL' => 'TCP',
'PROTOCOL' => $params['driverOptions']['protocol'] ?? 'TCP',
'HOST' => $params['host'],
'PORT' => $params['port'] ?? 1521,
],
Expand Down
12 changes: 9 additions & 3 deletions src/Driver/OCI8/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,21 @@
return $matches[1];
}

/** @throws Parser\Exception */
/**
* @throws Parser\Exception
* @throws Error
*/
public function prepare(string $sql): Statement
{
$visitor = new ConvertPositionalToNamedPlaceholders();

$this->parser->parse($sql, $visitor);

$statement = oci_parse($this->connection, $visitor->getSQL());
assert(is_resource($statement));
$statement = @oci_parse($this->connection, $visitor->getSQL());

Check warning on line 60 in src/Driver/OCI8/Connection.php

View check run for this annotation

Codecov / codecov/patch

src/Driver/OCI8/Connection.php#L60

Added line #L60 was not covered by tests

if (! is_resource($statement)) {
throw Error::new($this->connection);

Check warning on line 63 in src/Driver/OCI8/Connection.php

View check run for this annotation

Codecov / codecov/patch

src/Driver/OCI8/Connection.php#L62-L63

Added lines #L62 - L63 were not covered by tests
}

return new Statement($this->connection, $statement, $visitor->getParameterMap(), $this->executionMode);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Driver/PDO/PDOConnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ private function doConnect(
string $password,
array $options,
): PDO {
// see https://github.com/php/php-src/issues/16314
if (PHP_VERSION_ID < 80400 || ($options[PDO::ATTR_PERSISTENT] ?? false) === true) {
if (PHP_VERSION_ID < 80400) {
return new PDO($dsn, $username, $password, $options);
}

Expand Down
7 changes: 6 additions & 1 deletion src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use function is_float;
use function is_int;
use function is_string;
use function key;
use function max;
use function mb_strlen;
use function preg_quote;
Expand Down Expand Up @@ -195,7 +196,11 @@ public function getEnumDeclarationSQL(array $column): string
throw ColumnValuesRequired::new($this, 'ENUM');
}

return $this->getStringTypeDeclarationSQL(['length' => max(...array_map(mb_strlen(...), $column['values']))]);
$length = count($column['values']) > 1
? max(...array_map(mb_strlen(...), $column['values']))
: mb_strlen($column['values'][key($column['values'])]);

return $this->getStringTypeDeclarationSQL(['length' => $length]);
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/Driver/AbstractOracleDriver/EasyConnectStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ public static function connectionParametersProvider(): iterable
'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=41521))'
. '(CONNECT_DATA=(SID=XE)(INSTANCE_NAME=SALES)(SERVER=POOLED)))',
],
'tcps-params' => [
[
'host' => 'localhost',
'port' => 41521,
'dbname' => 'XE',
'instancename' => 'SALES',
'pooled' => true,
'driverOptions' => ['protocol' => 'TCPS'],
],
'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=localhost)(PORT=41521))'
. '(CONNECT_DATA=(SID=XE)(INSTANCE_NAME=SALES)(SERVER=POOLED)))',
],
];
}
}
68 changes: 68 additions & 0 deletions tests/Functional/Driver/OCI8/ConnectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Tests\Functional\Driver\OCI8;

use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;
use Throwable;

class ConnectionTest extends FunctionalTestCase
{
public static function setUpBeforeClass(): void
{
if (TestUtil::isDriverOneOf('oci8')) {
return;
}

self::markTestSkipped('This test requires the oci8 driver.');
}

public function testPrepareThrowsErrorOnConnectionLost(): void
{
$this->markConnectionNotReusable();
$this->killCurrentSession();

$this->expectException(DriverException::class);

$this->connection->prepare('SELECT * FROM 1');
}

/**
* Kill the current session, by using another connection
* Oracle doesn't allow you to terminate the current session, so we use a second connection
*/
private function killCurrentSession(): void
{
$row = $this->connection->fetchNumeric(
<<<'SQL'
SELECT SID, SERIAL#
FROM V$SESSION
WHERE AUDSID = USERENV('SESSIONID')
SQL,
);

self::assertNotFalse($row);
/** @psalm-suppress PossiblyUndefinedArrayOffset */
[$sid, $serialNumber] = $row;

self::assertNotNull($sid, 'SID is missing.');
self::assertNotNull($serialNumber, 'Serial number is missing.');

$params = TestUtil::getConnectionParams();
$params['driverOptions']['exclusive'] = true;
$secondConnection = DriverManager::getConnection($params);

$sessionParam = $this->connection->quote($sid . ', ' . $serialNumber);
$secondConnection->executeStatement('ALTER SYSTEM DISCONNECT SESSION ' . $sessionParam . ' IMMEDIATE');

// Ensure OCI driver is aware of connection state change by executing any statement
try {
$this->connection->executeStatement('INVALID SQL');
} catch (Throwable) {
}
}
}
9 changes: 9 additions & 0 deletions tests/Platforms/AbstractMySQLPlatformTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,4 +701,13 @@ protected function createComparator(): Comparator
new ComparatorConfig(),
);
}

/** @return array<string, array{array<string>, string}> */
public static function getEnumDeclarationSQLProvider(): array
{
return [
'single value' => [['foo'], "ENUM('foo')"],
'multiple values' => [['foo', 'bar1'], "ENUM('foo', 'bar1')"],
];
}
}
Loading