From fa14f79ebce1aaa51c7ecd76711affa60907d029 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Fri, 16 Feb 2024 16:10:07 +0100 Subject: [PATCH] Fix scope of routes with method name in production Phar --- scoper.inc.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scoper.inc.php b/scoper.inc.php index 0bf273d4..91f4f78a 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -136,9 +136,9 @@ static function (string $filePath, string $prefix, string $contents): string { ); }, - // Fix error templates (e.g. /vendor/symfony/error-handler/Resources/views) + // Disable HtmlErrorRenderer::fileExcerpt breaking due to high memory load static function (string $filePath, string $prefix, string $contents): string { - if (!str_starts_with($filePath, 'vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php')) { + if ('vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php' !== $filePath) { return $contents; } @@ -149,11 +149,20 @@ static function (string $filePath, string $prefix, string $contents): string { // 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')) { + if ('vendor/symfony/http-kernel/Kernel.php' !== $filePath) { return $contents; } return str_replace("\$buildDir . '/' . \$class . '.php'", "\$buildDir.'/'.str_replace('".$prefix."_', '', \$class).'.php'", $contents); }, + + // Fix routes controllers with method argument + static function (string $filePath, string $prefix, string $contents): string { + if (!str_starts_with($filePath, 'api/Resources/cache/')) { + return $contents; + } + + return str_replace("'Contao\\\\ManagerApi\\\\", "'$prefix\\\\Contao\\\\ManagerApi\\\\", $contents); + }, ], ];