Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #5991: Adds Convert Symlinks Option #5992

Open
wants to merge 16 commits into
base: 12.x
Choose a base branch
from

Conversation

rwagner00
Copy link
Contributor

@rwagner00 rwagner00 commented May 8, 2024

Resolves: #5991

This PR adds a convert-symlink option to the archive-dump command which will convert symlinks to standard/static files and directories in order to resolve a bug where symlinks external to the project would cause an error on dump.

@@ -140,7 +142,8 @@ public function dump(array $options = [
protected function prepareArchiveDir(): void
{
$this->filesystem = new Filesystem();
$this->archiveDir = FsUtils::tmpDir(self::ARCHIVES_DIR_NAME);
// $this->archiveDir = FsUtils::tmpDir(self::ARCHIVES_DIR_NAME);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be restored to its original state

$this->logger()->info(var_export($this->archiveDir, true));

// If symlinks are disabled, convert symlinks to full content.
if (is_dir($this->archiveDir)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't archiveDir always be a directory? If creating it might fail, then we should fail-fast above rather than nesting everything under this 'if'.


$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->archiveDir), RecursiveIteratorIterator::SELF_FIRST);

foreach ($iterator as $file) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to break this into a separate function, so that we could have a docblock explaining the purpose. The 'convert-symlinks' could be passed in as a named parameter (rather than passing all of $options).

@rwagner00
Copy link
Contributor Author

@greg-1-anderson Testing added, documentation provided.

Copy link
Member

@greg-1-anderson greg-1-anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for providing a test. @weitzman, do you want to review?

@greg-1-anderson greg-1-anderson changed the title Issue #5991 -- Adds Convert Symlinks Option Fixes #5991: Adds Convert Symlinks Option May 29, 2024
@greg-1-anderson
Copy link
Member

I just noticed this needs to target the 13.x branch. Should port over without too much effort.

@@ -588,4 +593,71 @@ private function destinationCleanup(string $destination): string
}
return $destination;
}

/**
* Converts symlinks to full content for an archive.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what 'full content' means in this context.

*
* @return void
*/
public function convertSymlinks(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add param types and return types. Remove any duplicate info in the Doxygen.

Comment on lines +135 to +136
file_put_contents($linktarget, "This is a symlink target file.");
symlink($linktarget, $linkdestination);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We write to the sandbox and not hard code /tmp. Furthermore we register files for cleanup. This needs cleanup upon success or failure.

@rwagner00 rwagner00 changed the base branch from 12.x to 13.x May 29, 2024 19:36
@greg-1-anderson greg-1-anderson changed the base branch from 13.x to 12.x May 29, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants