Skip to content

Commit

Permalink
[TASK] Replace \PDO::PARAM_* constants with Connection::PARAM_*
Browse files Browse the repository at this point in the history
This change replaces the `\PDO::PARAM_*` constants with the TYPO3
`\TYPO3\CMS\Core\Database\Connection::PARAM_*` alternatives. This
aligns the testing-framework with the core and the communicated
best-practice.

The direct dependency to `ext-pdo` is removed right away.

Note: `doctrine/dbal 4+` dropps support for the \PDO integer constants.
       Using the `Connection` constants allows us to change the mapping
       in that class and consuming code, like extensions or this package
       automaticlly uses the correct enum class on upgrade.

Used command(s):

```shell
composer remove ext-pdo
```

Releases: main, 7
  • Loading branch information
sbuerk committed Oct 20, 2023
1 parent c833927 commit 5c61903
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions Classes/Core/Functional/Framework/DataHandling/ActionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\DataHandling\DataHandler;
Expand Down Expand Up @@ -539,11 +540,11 @@ protected function getVersionedId(string $tableName, $liveUid)
->where(
$queryBuilder->expr()->eq(
't3ver_oid',
$queryBuilder->createNamedParameter($liveUid, \PDO::PARAM_INT)
$queryBuilder->createNamedParameter($liveUid, Connection::PARAM_INT)
),
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter($workspaceId, \PDO::PARAM_INT)
$queryBuilder->createNamedParameter($workspaceId, Connection::PARAM_INT)
)
)
->executeQuery();
Expand All @@ -563,19 +564,19 @@ protected function getVersionedId(string $tableName, $liveUid)
->where(
$queryBuilder->expr()->eq(
'uid',
$queryBuilder->createNamedParameter($liveUid, \PDO::PARAM_INT)
$queryBuilder->createNamedParameter($liveUid, Connection::PARAM_INT)
),
$queryBuilder->expr()->eq(
't3ver_wsid',
$queryBuilder->createNamedParameter($workspaceId, \PDO::PARAM_INT)
$queryBuilder->createNamedParameter($workspaceId, Connection::PARAM_INT)
),
$queryBuilder->expr()->eq(
't3ver_oid',
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
),
$queryBuilder->expr()->eq(
't3ver_state',
$queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)
$queryBuilder->createNamedParameter(1, Connection::PARAM_INT)
)
)
->executeQuery();
Expand Down
3 changes: 2 additions & 1 deletion Classes/Core/Functional/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Core\ClassLoadingInformation;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
Expand Down Expand Up @@ -603,7 +604,7 @@ protected function getBackendUserRecordFromDatabase(int $userId): ?array

$result = $queryBuilder->select('*')
->from('be_users')
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($userId, \PDO::PARAM_INT)))
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($userId, Connection::PARAM_INT)))
->executeQuery();
return $result->fetchAssociative() ?: null;
}
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
},
"require": {
"php": ">= 7.4",
"ext-pdo": "*",
"guzzlehttp/psr7": "^2.4.3",
"phpunit/phpunit": "^9.5.25 || ^10.1",
"psr/container": "^1.1.0 || ^2.0.0",
Expand Down

0 comments on commit 5c61903

Please sign in to comment.