Bug #100282
openEnable _assets Symlinks (junctions) on Windows
0%
Description
Composer Install with TYPO3 12 do not create symlinks in Windows Operating System for public/_assets/[symlinks].
We hotfixed it with an Operating System check. Windows can use fileSystem->junction instead of fileSystem->relativeSymlink.
Could Windows Support be integrated in TYPO3 Core for Symlinks?
Class: \TYPO3\CMS\Core\Composer\PackageArtifactBuilder
Method: publishResources
Current code:
if (!$fileSystem->isSymlinkedDirectory($publicResourcesPath)) {
$fileSystem->relativeSymlink($fileSystemResourcesPath, $publicResourcesPath);
}
Hotfix code:
if (!$fileSystem->isSymlinkedDirectory($publicResourcesPath)) {
if (Platform::isWindows()) {
$fileSystem->junction($fileSystemResourcesPath, $publicResourcesPath);
} else {
$fileSystem->relativeSymlink($fileSystemResourcesPath, $publicResourcesPath);
}
}
Files
Updated by Steffen Mächtel about 1 year ago
Better Hotfix, also work on second `composer install` run on Windows:
File vendor\typo3\cms-core\Classes\Composer\PackageArtifactBuilder.php:
private function publishResources(array $installedTypo3Packages): void
{
$fileSystem = new Filesystem();
$baseDir = $this->config->get('base-dir');
foreach ($installedTypo3Packages as [$composerPackage, $path, $extensionKey]) {
$fileSystemResourcesPath = $path . '/Resources/Public';
if (str_contains($path, 'ext/' . $extensionKey) || !file_exists($fileSystemResourcesPath)) {
continue;
}
$relativePath = substr($fileSystemResourcesPath, strlen($baseDir));
[$relativePrefix] = explode('Resources/Public', $relativePath);
if (\Composer\Util\Platform::isWindows()) {
$relativePrefix = str_replace('\\', '/', $relativePrefix);
}
$publicResourcesPath = $fileSystem->normalizePath($this->config->get('web-dir') . '/_assets/' . md5($relativePrefix));
$fileSystem->ensureDirectoryExists(dirname($publicResourcesPath));
if (\Composer\Util\Platform::isWindows()) {
if (!$fileSystem->isJunction($publicResourcesPath)) {
$fileSystem->junction($fileSystemResourcesPath, $publicResourcesPath);
}
} else {
if (!$fileSystem->isSymlinkedDirectory($publicResourcesPath)) {
$fileSystem->relativeSymlink($fileSystemResourcesPath, $publicResourcesPath);
}
}
}
}
Updated by Steffen Mächtel about 1 year ago
- Related to Bug #98434: Extension assets are not exported with Composer installers v4 on Windows platform added
Updated by Kurt Gusbeth almost 1 year ago
Well, I think this patch is really a "should have", but I had 2 problems with it:
1. Platform is not defined. An
use xxx/yyy/Platform
is missing here.
2. $relativePrefix has not a correct value. At my windows installation, $relativePrefix is like "\vendor/typo3/cms-backend/".
The correct string should be: "/vendor/typo3/cms-backend/"
So I needed to add this code:
$relativePrefix = str_replace('\\', '/', $relativePrefix);
After that the patch worked correct and created the files in _assets.
Updated by Steffen Mächtel 9 months ago
Kurt Gusbeth wrote in #note-3:
Well, I think this patch is really a "should have", but I had 2 problems with it:
1. Platform is not defined. An
use xxx/yyy/Platform
is missing here.
2. $relativePrefix has not a correct value. At my windows installation, $relativePrefix is like "\vendor/typo3/cms-backend/".
The correct string should be: "/vendor/typo3/cms-backend/"
So I needed to add this code:
[...]
After that the patch worked correct and created the files in _assets.
Correct. I updated my hotfix code. Thank you.
Updated by Steffen Mächtel 9 months ago
Updated by Steffen Mächtel 8 months ago
Problem is fixed TYPO3 12.4.6 => https://forge.typo3.org/issues/98434
This issue can also be closed.