#91800Calculation of the relative path of the Typo3 library during CoreUpdate in combination with softlinks in the document path
Description
Hello,
i have at my new webhoster there is an unusual directory structure. It has a mixture of softlinks and real directories.
Simplified and similar to this example:
/abc/softlink :: <- Link to /abc
/abc/customer/htdocs :: <- real directory with Typo3
For whatever reason, the hoster has now set it up so that the document path is: /abc/softlink/customer/htdocs
Unfortunately CoreUpdateService does not work like this. Because in the method: CoreUpdateService#activateVersion($version) the “realpath()” is created by the path of the Typo3 library:
$newCoreLocation = @realpath($this->symlinkToCoreFiles . '/../') . '/typo3_src-' . $version;
But then the method CoreUpdateService#getRelativePath(…) is used:
$newCoreLocation = $this->getRelativePath($newCoreLocation);
However, CoreUpdateService#getRelativePath(…) directly uses the document path (Environment::getPublicPath()) without “normalizing” it with realpath.
At my webhosts this unusual softlink is in the root directory. This creates a totally long and relative path. Which does not even work.
Therefore, the method CoreUpdateService#getRelativePath(…) suggests this correction:
/**
* Get relative path to TYPO3 source directory from webroot
*
* @param string $absolutePath to TYPO3 source directory
* @return string relative path to TYPO3 source directory
*/
protected function getRelativePath($absolutePath)
{
$sourcePath = explode(DIRECTORY_SEPARATOR, @realpath(Environment::getPublicPath()));
$targetPath = explode(DIRECTORY_SEPARATOR, @realpath(rtrim($absolutePath, DIRECTORY_SEPARATOR)));
while (count($sourcePath) && count($targetPath) && $sourcePath[0] === $targetPath[0]) {
array_shift($sourcePath);
array_shift($targetPath);
}
return str_pad('', count($sourcePath) * 3, '...' . DIRECTORY_SEPARATOR) . implode(DIRECTORY_SEPARATOR, $targetPath) ;
}
So you can put “any” path in there and internally this method always works with the real paths.
Best regards
Clemens
Translated with www.DeepL.com/Translator (free version)
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[BUGFIX] Calculation of the relative path of the Typo3 library during CoreUpdate in combination with softlinks in the document path Resolves: #91800 Releases: main