Skip to content

Commit

Permalink
Revert Cleanup CachedContainer invalidation (#3867) (#3880)
Browse files Browse the repository at this point in the history
This reverts commit f0141af.
  • Loading branch information
samsonasik committed May 17, 2023
1 parent c018b8b commit 5e3afcb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 78 deletions.
10 changes: 9 additions & 1 deletion packages/Testing/PHPUnit/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ protected function getService(string $type): object
);
}

$object = self::$currentContainer->get($type);
try {
$object = self::$currentContainer->get($type);
} catch (Throwable $throwable) {
// clear compiled container cache, to trigger re-discovery
RectorKernel::clearCache();

throw $throwable;
}

if ($object === null) {
$message = sprintf('Service "%s" was not found', $type);
throw new ShouldNotHappenException($message);
Expand Down
7 changes: 0 additions & 7 deletions src/Exception/Cache/StaleContainerCacheException.php

This file was deleted.

67 changes: 0 additions & 67 deletions src/Kernel/CacheInvalidatingContainer.php

This file was deleted.

5 changes: 2 additions & 3 deletions src/Kernel/CachedContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public function build(array $configFiles, string $hash, callable $containerBuild
if (file_exists($file)) {
require_once $file;
$className = '\\' . __NAMESPACE__ . '\\' . $className;
$cachedContainer = new $className();
if (! $cachedContainer instanceof ContainerInterface) {
$container = new $className();
if (! $container instanceof ContainerInterface) {
throw new ShouldNotHappenException();
}
$container = new CacheInvalidatingContainer($cachedContainer);
} else {
$container = ($containerBuilderCallback)($configFiles);

Expand Down

0 comments on commit 5e3afcb

Please sign in to comment.