This patch fixes two issues when generating symlinks to the public
extension resources (Public/Resources) into the _assets folder during
Composer installation.
First, directory symlinks can't be created the same way on Windows as
on Unix platforms. The creation requires elevated rights, and the
required command is named differently as well. Junctions should be used
on Windows instead, because they do not need elevated privileges to be
created.
When installing a TYPO3 extension via Composer, its Resources/Public
folder is getting symlinked to the publicly accessible _assets folder.
Until now, this process only used the Unix specific functions provided
by Composer. It did not create any symlinks on Windows based
installations, without generating any error message.
This patch adds the same checks and platform-specific functions used by
Composer when symlinking packages from a local path repository.
The second issue that has been addressed is the naming of the symlinks
themselves. When a Resources/Public directory is symlinked into the
_assets folder, the symlink will be named using an md5 hash based on
parts of the extension's installation path on the filesystem. During
Composer installation, this relative path is derived from the
absolute path provided by Composer. As Windows uses a different default
path separator (backslash) compared to Unix (forward slash), the
relative path will be different between both platforms, resulting in a
different md5 hash being generated.
Absolute path on Unix:
/path/to/typo3/vendor/mycompany/myext
Absolute path on Windows:
C:\path\to\typo3\vendor/mycompany/myext
Relative path to be used for the hash on Unix:
/vendor/mycompany/myext
Relative path to be used for the hash on Windows:
\vendor/mycompany/myext
If an uri into the _assets folder is to be generated in either frontend
or backend, the md5 hash will be always be generated by using forward
slashes, resulting in incorrect links on Windows installations.
This difference has been solved by replacing all backslashes in the
absolute extension installation path into forward slashes on Windows
installations, so the symlink will be named correctly from the
beginning.