Assets are not copied from style archive when using symlinks

Kirby

Well-known member
Affected version
2.2.9
If the path to the temporary directory does contain a symlink somewhere, copying files from a style archive does fail due to
PHP:
$stdPath = File::stripRootPathPrefix($pathname, $tempDir);

if (!$this->isWithinAssetPath($stdPath, $assetPaths))
{
    continue;
}
As $tempDir does not contain the realpath, calling stripRootPathPrefix does nothing and thus isWithinAssetPath returns false which skips the file.

Suggested Solution
Call realpath before returing the path in \XF\Util\File::getTempDir()
 
Can confirm this is still relevant in 2.3.6.

Modifying /src/XF/Util/File.php and changing the return statement in public static function getTempDir() to
return realpath($path) ?: $path; worked perfect!

Thank you @Kirby!
 
Back
Top Bottom