Skip to content

Commit

Permalink
Update MySql.php
Browse files Browse the repository at this point in the history
fix for spatie/laravel-backup#1840

ability to use skip SSL
  • Loading branch information
diadal committed Sep 17, 2024
1 parent e451dac commit 9c43425
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Databases/MySql.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class MySql extends DbDumper
{
protected bool $skipSsl = false;

protected bool $skipComments = true;

protected bool $useExtendedInserts = true;
Expand Down Expand Up @@ -42,6 +44,13 @@ public function __construct()
$this->port = 3306;
}

public function setSkipSsl(bool $skipSsl): self
{
$this->skipSsl = $skipSsl;

return $this;
}

public function skipComments(): self
{
$this->skipComments = true;
Expand Down Expand Up @@ -119,6 +128,8 @@ public function dontUseQuick(): self
return $this;
}



public function setDefaultCharacterSet(string $characterSet): self
{
$this->defaultCharacterSet = $characterSet;
Expand Down Expand Up @@ -238,15 +249,15 @@ public function getDumpCommand(string $dumpFile, string $temporaryCredentialsFil
}

if (! empty($this->defaultCharacterSet)) {
$command[] = '--default-character-set='.$this->defaultCharacterSet;
$command[] = '--default-character-set=' . $this->defaultCharacterSet;
}

foreach ($this->extraOptions as $extraOption) {
$command[] = $extraOption;
}

if ($this->setGtidPurged !== 'AUTO') {
$command[] = '--set-gtid-purged='.$this->setGtidPurged;
$command[] = '--set-gtid-purged=' . $this->setGtidPurged;
}

if (! $this->dbNameWasSetAsExtraOption) {
Expand All @@ -270,7 +281,6 @@ public function getDumpCommand(string $dumpFile, string $temporaryCredentialsFil
}

return $this->echoToFile($finalDumpCommand, $dumpFile);

}

public function getContentsOfCredentialsFile(): string
Expand All @@ -286,6 +296,10 @@ public function getContentsOfCredentialsFile(): string
$contents[] = "host = '{$this->host}'";
}

if ($this->skipSsl) {
$contents[] = "skip-ssl";
}

return implode(PHP_EOL, $contents);
}

Expand Down

0 comments on commit 9c43425

Please sign in to comment.