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
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
strategy:
matrix:
php:
- 8.0
- 8.1
- 8.2
- 8.3
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Unreleased:
* Drop PHP 8.0 support, PHP >= 8.1 is now required
* Add ResetInterface on ConnectionPool, UnitOfWork and Repository to reset state between requests (worker mode)

3.12.1 (2025-12-16):
* Fix Hydrator: disable identity map now prevent storing entities

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"type": "library",
"license": "Apache-2.0",
"require": {
"php": ">=8.0",
"php": ">=8.1",
"aura/sqlquery": "^2.6 || ^3.0",
"doctrine/cache": "^1.6",
"symfony/property-access": "^6.0 || ^7.0"
Expand Down
7 changes: 6 additions & 1 deletion src/Ting/ConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use CCMBenchmark\Ting\Exceptions\ConnectionException;
use CCMBenchmark\Ting\Logger\DriverLoggerInterface;

class ConnectionPool implements ConnectionPoolInterface
class ConnectionPool implements ConnectionPoolInterface, ResetInterface
{
/**
* @var array
Expand Down Expand Up @@ -226,4 +226,9 @@ public function getDriverClass($name)

return $this->connectionConfig[$name]['namespace'] . '\\Driver';
}

public function reset(): void
{
$this->closeAll();
}
}
9 changes: 8 additions & 1 deletion src/Ting/Repository/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@
use CCMBenchmark\Ting\Exceptions\RepositoryException;
use CCMBenchmark\Ting\MetadataRepository;
use CCMBenchmark\Ting\Query\QueryFactory;
use CCMBenchmark\Ting\ResetInterface;
use CCMBenchmark\Ting\Serializer\SerializerFactoryInterface;
use CCMBenchmark\Ting\UnitOfWork;
use Doctrine\Common\Cache\Cache;

/**
* @template T
*/
abstract class Repository
abstract class Repository implements ResetInterface
{
public const QUERY_SELECT = 'select';
public const QUERY_INSERT = 'insert';
Expand Down Expand Up @@ -403,4 +404,10 @@ public function getMetadata()
{
return $this->metadata;
}

public function reset(): void
{
$this->unitOfWork->reset();
$this->connection = $this->metadata->getConnection($this->connectionPool);
}
}
8 changes: 8 additions & 0 deletions src/Ting/ResetInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace CCMBenchmark\Ting;

interface ResetInterface
{
public function reset(): void;
}
11 changes: 10 additions & 1 deletion src/Ting/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
use CCMBenchmark\Ting\Repository\Metadata;
use WeakMap;

class UnitOfWork implements PropertyListenerInterface
class UnitOfWork implements PropertyListenerInterface, ResetInterface
{
public const STATE_NEW = 1;
public const STATE_MANAGED = 2;
Expand Down Expand Up @@ -219,6 +219,15 @@ public function detachAll(): void
$this->entities = new WeakMap();
}

/**
* Reset state between requests (worker mode: FrankenPHP, Swoole, RoadRunner, etc.)
*/
public function reset(): void
{
$this->detachAll();
$this->statements = [];
}

/**
* Flag the entity to be deleted on next process
*
Expand Down
Loading