From 5384ecbb521f20970eeefd65aec46a2f97de2aab Mon Sep 17 00:00:00 2001 From: Ralf Lang Date: Tue, 20 May 2025 13:50:05 +0200 Subject: [PATCH 1/3] fix: Proxy mode no longer fails on older composer versions < 2.7 due to missing named property on filesystem helper --- src/ApplicationLinker.php | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/ApplicationLinker.php b/src/ApplicationLinker.php index f835ec3..1812196 100644 --- a/src/ApplicationLinker.php +++ b/src/ApplicationLinker.php @@ -9,6 +9,7 @@ use DirectoryIterator; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; +use ReflectionMethod; class ApplicationLinker { @@ -176,16 +177,30 @@ public function run(): void continue; } $this->filesystem->ensureDirectoryExists($appWebDir . DIRECTORY_SEPARATOR . $relativePath); - $pathProxyToAutoloader = $this->filesystem->findShortestPath( - $appWebDir . DIRECTORY_SEPARATOR . $relativePathName, - $vendorDir . DIRECTORY_SEPARATOR . 'autoload.php', - preferRelative: true - ); - $pathProxyToFile = $this->filesystem->findShortestPath( - $appWebDir . DIRECTORY_SEPARATOR . $relativePathName, - $appVendorDir . DIRECTORY_SEPARATOR . $relativePathName, - preferRelative: true - ); + $reflection = new ReflectionMethod($this->filesystem, 'findShortestPath'); + if ($reflection->getNumberOfParameters() >= 4) { + $pathProxyToAutoloader = $this->filesystem->findShortestPath( + $appWebDir . DIRECTORY_SEPARATOR . $relativePathName, + $vendorDir . DIRECTORY_SEPARATOR . 'autoload.php', + preferRelative: true + ); + $pathProxyToFile = $this->filesystem->findShortestPath( + $appWebDir . DIRECTORY_SEPARATOR . $relativePathName, + $appVendorDir . DIRECTORY_SEPARATOR . $relativePathName, + preferRelative: true + ); + } else { + // Older composer versions don't support preferRelative + $pathProxyToAutoloader = $this->filesystem->findShortestPath( + $appWebDir . DIRECTORY_SEPARATOR . $relativePathName, + $vendorDir . DIRECTORY_SEPARATOR . 'autoload.php', + ); + $pathProxyToFile = $this->filesystem->findShortestPath( + $appWebDir . DIRECTORY_SEPARATOR . $relativePathName, + $appVendorDir . DIRECTORY_SEPARATOR . $relativePathName, + ); + } + $originalContent = file_get_contents($appVendorDir . DIRECTORY_SEPARATOR . $relativePathName); if (str_contains((string) $originalContent, ' Date: Tue, 20 May 2025 14:27:09 +0200 Subject: [PATCH 2/3] fix: Add $APP_TEMPLATE constants to local files to support constant-based template paths forced to vendor dir --- src/HordeLocalFileWriter.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/HordeLocalFileWriter.php b/src/HordeLocalFileWriter.php index 64a38af..ee8c525 100644 --- a/src/HordeLocalFileWriter.php +++ b/src/HordeLocalFileWriter.php @@ -56,7 +56,7 @@ private function processApp(string $app): void $hordeBaseDir = $this->vendorHordeDir; } $hordeLocalFileContent = sprintf( - "configDir ); @@ -65,6 +65,14 @@ private function processApp(string $app): void $hordeLocalFileContent .= $this->_legacyWorkaround($this->filesystem->normalizePath($this->vendorDir)); $hordeLocalFileContent .= "require_once('" . $this->vendorDir . "/autoload.php');"; } + $appNameUpper = strtoupper($name); + $hordeLocalFileContent .= sprintf( + "\nif (!defined('%s_TEMPLATES')) define('%s_TEMPLATES', '%s');\n", + $appNameUpper, + $appNameUpper, + $this->vendorDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . 'templates', + ); + $autoloadExtraFilePath = $this->baseDir . '/var/config/autoload-extra.php'; if (file_exists($autoloadExtraFilePath)) { $hordeLocalFileContent .= "\nrequire_once('$autoloadExtraFilePath')\n"; From c4a61c3388e5472726482c5044b7ce37dbdab094 Mon Sep 17 00:00:00 2001 From: Ralf Lang Date: Tue, 20 May 2025 12:32:38 +0000 Subject: [PATCH 3/3] fix: Explicitly set registry template dir to vendor dir for all apps. --- src/RegistrySnippetFileWriter.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/RegistrySnippetFileWriter.php b/src/RegistrySnippetFileWriter.php index 4a5d806..faa0c0b 100644 --- a/src/RegistrySnippetFileWriter.php +++ b/src/RegistrySnippetFileWriter.php @@ -84,10 +84,12 @@ public function run(): void ' * - var/config/horde/registry-sub.domain.org.php' . PHP_EOL . ' */' . PHP_EOL; + $appInVendorDir = $this->baseDir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $appVendor . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR; if ($app == 'horde/horde') { $registryAppFilename = $this->configRegistryDir . '/01-location-' . $appName . '.php'; $registryAppSnippet .= - '$this->applications[\'horde\'][\'fileroot\'] = $app_fileroot;' . PHP_EOL . + '$this->applications[\'' . $appName . '\'][\'fileroot\'] = \'' . $appInVendorDir . '\';' . PHP_EOL . + '$this->applications[\'' . $appName . '\'][\'templates\'] = \'' . $appInVendorDir . 'templates' . DIRECTORY_SEPARATOR . '\';' . PHP_EOL . '$this->applications[\'horde\'][\'webroot\'] = $app_webroot;' . PHP_EOL . '$this->applications[\'horde\'][\'jsfs\'] = $deployment_fileroot . \'/js/horde/\';' . PHP_EOL . '$this->applications[\'horde\'][\'jsuri\'] = $deployment_webroot . \'js/horde/\';' . PHP_EOL . @@ -98,7 +100,6 @@ public function run(): void } else { // A registry snippet should ensure the install dir is known $registryAppFilename = $this->configRegistryDir . '/02-location-' . $appName . '.php'; - $appInVendorDir = $this->baseDir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $appVendor . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR; $registryAppSnippet .= '$this->applications[\'' . $appName . '\'][\'fileroot\'] = \'' . $appInVendorDir . '\';' . PHP_EOL . '$this->applications[\'' . $appName . '\'][\'templates\'] = \'' . $appInVendorDir . 'templates' . DIRECTORY_SEPARATOR . '\';' . PHP_EOL .