Skip to content
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
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
FROM php:8.0-cli-alpine3.13
FROM php:8.4-cli-alpine3.22

RUN apk add --no-cache \
RUN apk update && \
apk add --no-cache \
libzip-dev \
git \
openssl-dev && \
docker-php-ext-install -j$(nproc) \
zip

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer

RUN apk add --no-cache --virtual .phpize_deps $PHPIZE_DEPS && \
pecl install xdebug-3.1.1 && \
RUN apk add --no-cache --virtual .phpize_deps $PHPIZE_DEPS linux-headers && \
pecl install xdebug-3.4.7 && \
docker-php-ext-enable xdebug && \
rm -rf /usr/share/php7 && \
rm -rf /tmp/pear && \
apk del .phpize_deps

Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ DOCKER_PHP_SERVICE=php
start: erase cache-folders build composer-install bash

erase:
docker-compose down -v
docker compose down -v

build:
docker-compose build && \
docker-compose pull
docker compose build && \
docker compose pull

cache-folders:
mkdir -p ~/.composer && chown ${UID}:${GID} ~/.composer

composer-install:
docker-compose run --rm -u ${UID}:${GID} ${DOCKER_PHP_SERVICE} composer install
docker compose run --rm -u ${UID}:${GID} ${DOCKER_PHP_SERVICE} composer install

bash:
docker-compose run --rm -u ${UID}:${GID} ${DOCKER_PHP_SERVICE} sh
docker compose run --rm -u ${UID}:${GID} ${DOCKER_PHP_SERVICE} sh

logs:
docker-compose logs -f ${DOCKER_PHP_SERVICE}
docker compose logs -f ${DOCKER_PHP_SERVICE}

.PHONY: tests
tests:
docker-compose run --rm -u ${UID}:${GID} ${DOCKER_PHP_SERVICE} phpunit
docker compose run --rm -u ${UID}:${GID} ${DOCKER_PHP_SERVICE} phpunit
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
}
},
"require": {
"php": "^7.4 | ^8.0",
"php": "^7.4 || ^8.0",
"pccomponentes/transaction": "^2.0",
"doctrine/dbal": "^2.10 | ^3.0"
"doctrine/dbal": "^2.10 || ^3.0 || ^4.0"
},
"require-dev": {
"pccomponentes/coding-standard": "^1.0",
Expand Down
7 changes: 6 additions & 1 deletion src/Driver/DBAL/DBALTransactionalConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ public function __construct(Connection $DBALConnection, bool $nestTransactionsWi
$this->DBALConnection = $DBALConnection;

if (true === $nestTransactionsWithSavepoints) {
$this->DBALConnection->setNestTransactionsWithSavepoints(true);
// In DBAL 4+, savepoints are always enabled for nested transactions
// The setNestTransactionsWithSavepoints method is deprecated and will be removed in DBAL 5
// We only call it if it exists to maintain backward compatibility with DBAL 2.x and 3.x
if (\method_exists($this->DBALConnection, 'setNestTransactionsWithSavepoints')) {
@$this->DBALConnection->setNestTransactionsWithSavepoints(true);
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions tests/Driver/DBAL/DBALTransactionalConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,25 @@ public function given_dbal_connection_when_is_not_in_transaction_active_then_ret
$transactionalConnection = new DBALTransactionalConnection($DBALConnection);
$this->assertFalse($transactionalConnection->isTransactionActive());
}

/**
* @test
*/
public function given_dbal_connection_with_nest_transactions_enabled_when_construct_then_works_correctly()
{
$DBALConnection = $this->createMock(Connection::class);

// In DBAL 4+, setNestTransactionsWithSavepoints is deprecated
// The code should handle this gracefully by checking if method exists
if (\method_exists($DBALConnection, 'setNestTransactionsWithSavepoints')) {
$DBALConnection
->expects($this->once())
->method('setNestTransactionsWithSavepoints')
->with(true)
;
}

$transactionalConnection = new DBALTransactionalConnection($DBALConnection, true);
$this->assertInstanceOf(DBALTransactionalConnection::class, $transactionalConnection);
}
}