Skip to content

Commit

Permalink
#60: Fix for incorrect caching mechanism of getFilename method (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbiarda authored Jan 24, 2023
1 parent b9e70a4 commit 4d37958
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Engines/MySql/Sandbox/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Output\ConsoleOutput;

use function array_key_exists;

class Export extends Command implements CommandInterface, CleanupInterface
{
private RemoteConnectionInterface $connection;
private Ssl $ssl;
private Random $random;
private ?string $filename = null;
/** @var array<string, string> */
private array $filenames = [];
private Configuration $configuration;
// phpcs:ignore SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification
private array $properties;
Expand Down Expand Up @@ -148,8 +151,8 @@ private function compressOutput(): bool

private function getFilename(string $environmentName): string
{
if ($this->filename) {
return $this->filename;
if (array_key_exists($environmentName, $this->filenames)) {
return $this->filenames[$environmentName];
}

$path = $this->configuration->getNode('connections/rds/dump-path');
Expand All @@ -161,7 +164,7 @@ private function getFilename(string $environmentName): string
. ($this->compressOutput() ? '.gz' : '.sql');
} while (file_exists($file));

$this->filename = $file;
return $this->filename;
$this->filenames[$environmentName] = $file;
return $this->filenames[$environmentName];
}
}

0 comments on commit 4d37958

Please sign in to comment.