From 5cb115112a69baebe3ae2607a24b70312968fbf9 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Fri, 16 Feb 2024 15:26:27 +0100 Subject: [PATCH] Fix scope of Symfony container cache in production Phar --- scoper.inc.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scoper.inc.php b/scoper.inc.php index a4ce3efe..0bf273d4 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -146,5 +146,14 @@ static function (string $filePath, string $prefix, string $contents): string { {', "private function fileExcerpt(string \$file, int \$line, int \$srcContext = 3) : string { return '';", $contents); }, + + // Fix prod container cache path + static function (string $filePath, string $prefix, string $contents): string { + if (!str_starts_with($filePath, 'vendor/symfony/http-kernel/Kernel.php')) { + return $contents; + } + + return str_replace("\$buildDir . '/' . \$class . '.php'", "\$buildDir.'/'.str_replace('".$prefix."_', '', \$class).'.php'", $contents); + }, ], ];