Project

General

Profile

Actions

Bug #91800

open

Calculation of the relative path of the Typo3 library during CoreUpdate in combination with softlinks in the document path

Added by C. Gogolin over 4 years ago. Updated over 4 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Install Tool
Start date:
2020-07-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
core update softlinks
Complexity:
medium
Is Regression:
Sprint Focus:

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)

Actions

Also available in: Atom PDF