Sim
Well-known member
- Affected version
- XF 2.1
One of my addons uses composer packages, one of which (Carbon) creates a symlink from the
During the build cleanup process, XenForo attempts to delete the
This is because the code is resolving the "real path" of the file and deleting that, rather than deleting the symlink itself.
This can be fixed by checking whether the file is a symlink and deleting it directly.
I have verified that this change correctly removes symlinks and allows the build process to complete successfully.
vendor/bin
folder to an executable in the package.During the build cleanup process, XenForo attempts to delete the
_build
directory, however it fails due to one of the directories not being empty.This is because the code is resolving the "real path" of the file and deleting that, rather than deleting the symlink itself.
PHP:
public static function deleteDirectory($path)
...
$files = self::getRecursiveDirectoryIterator($path);
foreach ($files AS $file)
{
if ($file->isDir())
{
rmdir($file->getRealPath());
}
else
{
unlink($file->getRealPath()); // <-- does not delete symlinks
}
}
...
}
This can be fixed by checking whether the file is a symlink and deleting it directly.
PHP:
public static function deleteDirectory($path)
{
...
$files = self::getRecursiveDirectoryIterator($path);
foreach ($files AS $file)
{
if ($file->isDir())
{
rmdir($file->getRealPath());
}
elseif ($file->isLink())
{
unlink($file->getPathname()); // unlink symlinks
}
else
{
unlink($file->getRealPath());
}
}
...
}
I have verified that this change correctly removes symlinks and allows the build process to complete successfully.