Skip to content

Commit 5637c4c

Browse files
Fix --lock-tables option
You can now use both --lock-tables=true --lock-tables=false
1 parent a5136fa commit 5637c4c

File tree

6 files changed

+102
-65
lines changed

6 files changed

+102
-65
lines changed

src/Backup/Source/Mysqldump.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use phpbu\App\Backup\Restore\Plan;
55
use phpbu\App\Backup\Target;
66
use phpbu\App\Cli\Executable;
7+
use phpbu\App\Cli\Executable\Mysql;
8+
use phpbu\App\Cli\Executable\Mysqlimport;
79
use phpbu\App\Exception;
810
use phpbu\App\Result;
911
use phpbu\App\Util;
@@ -132,7 +134,7 @@ class Mysqldump extends SimulatorExecutable implements Simulator, Restorable
132134
* Lock tables option
133135
* --lock-tables
134136
*
135-
* @var bool
137+
* @var string
136138
*/
137139
private $lockTables;
138140

@@ -238,7 +240,7 @@ public function setup(array $conf = [])
238240
$this->sslCa = Util\Arr::getValue($conf, 'sslCa', '');
239241
$this->hexBlob = Util\Str::toBoolean(Util\Arr::getValue($conf, 'hexBlob', ''), false);
240242
$this->quick = Util\Str::toBoolean(Util\Arr::getValue($conf, 'quick', ''), false);
241-
$this->lockTables = Util\Str::toBoolean(Util\Arr::getValue($conf, 'lockTables', ''), false);
243+
$this->lockTables = Util\Arr::getValue($conf, 'lockTables', '');
242244
$this->singleTransaction = Util\Str::toBoolean(Util\Arr::getValue($conf, 'singleTransaction', ''), false);
243245
$this->compress = Util\Str::toBoolean(Util\Arr::getValue($conf, 'compress', ''), false);
244246
$this->skipExtendedInsert = Util\Str::toBoolean(Util\Arr::getValue($conf, 'skipExtendedInsert', ''), false);
@@ -270,11 +272,11 @@ protected function setupSourceData(array $conf)
270272
/**
271273
* Execute the backup
272274
*
273-
* @see \phpbu\App\Backup\Source
274-
* @param \phpbu\App\Backup\Target $target
275+
* @param Target $target
275276
* @param \phpbu\App\Result $result
276-
* @return \phpbu\App\Backup\Source\Status
277+
* @return Status
277278
* @throws \phpbu\App\Exception
279+
*@see \phpbu\App\Backup\Source
278280
*/
279281
public function backup(Target $target, Result $result) : Status
280282
{
@@ -318,9 +320,9 @@ public function backup(Target $target, Result $result) : Status
318320
/**
319321
* Restore the backup
320322
*
321-
* @param \phpbu\App\Backup\Target $target
322-
* @param \phpbu\App\Backup\Restore\Plan $plan
323-
* @return \phpbu\App\Backup\Source\Status
323+
* @param Target $target
324+
* @param Plan $plan
325+
* @return Status
324326
*/
325327
public function restore(Target $target, Plan $plan): Status
326328
{
@@ -353,8 +355,8 @@ public function restore(Target $target, Plan $plan): Status
353355
/**
354356
* Create the Executable to run the mysqldump command.
355357
*
356-
* @param \phpbu\App\Backup\Target $target
357-
* @return \phpbu\App\Cli\Executable
358+
* @param Target $target
359+
* @return Executable
358360
*/
359361
protected function createExecutable(Target $target) : Executable
360362
{
@@ -391,8 +393,8 @@ protected function createExecutable(Target $target) : Executable
391393
/**
392394
* Create backup status.
393395
*
394-
* @param \phpbu\App\Backup\Target $target
395-
* @return \phpbu\App\Backup\Source\Status
396+
* @param Target $target
397+
* @return Status
396398
*/
397399
protected function createStatus(Target $target) : Status
398400
{
@@ -414,7 +416,7 @@ protected function createStatus(Target $target) : Status
414416
/**
415417
* Can compression be handled via pipe operator.
416418
*
417-
* @param \phpbu\App\Backup\Target $target
419+
* @param Target $target
418420
* @return bool
419421
*/
420422
private function isHandlingCompression(Target $target) : bool
@@ -425,7 +427,7 @@ private function isHandlingCompression(Target $target) : bool
425427
/**
426428
* Return dump target path.
427429
*
428-
* @param \phpbu\App\Backup\Target $target
430+
* @param Target $target
429431
* @return string
430432
*/
431433
private function getDumpTarget(Target $target) : string
@@ -436,11 +438,11 @@ private function getDumpTarget(Target $target) : string
436438
/**
437439
* Create the Executable to run the mysql command.
438440
*
439-
* @return \phpbu\App\Cli\Executable\Mysql
441+
* @return Mysql
440442
*/
441-
private function createMysqlExecutable(): Executable\Mysql
443+
private function createMysqlExecutable(): Mysql
442444
{
443-
$executable = new Executable\Mysql($this->pathToMysql);
445+
$executable = new Mysql($this->pathToMysql);
444446
$executable->credentials($this->user, $this->password)
445447
->useHost($this->host)
446448
->usePort($this->port)
@@ -457,11 +459,11 @@ private function createMysqlExecutable(): Executable\Mysql
457459
* @param string $sourceFilename
458460
* @param string $targetDatabase
459461
*
460-
* @return \phpbu\App\Cli\Executable\Mysqlimport
462+
* @return Mysqlimport
461463
*/
462-
private function createMysqlimportExecutable(string $sourceFilename, string $targetDatabase): Executable\Mysqlimport
464+
private function createMysqlimportExecutable(string $sourceFilename, string $targetDatabase): Mysqlimport
463465
{
464-
$executable = new Executable\Mysqlimport($this->pathToMysqlimport);
466+
$executable = new Mysqlimport($this->pathToMysqlimport);
465467
$executable->setSourceAndTarget($sourceFilename, $targetDatabase)
466468
->credentials($this->user, $this->password)
467469
->useHost($this->host)

0 commit comments

Comments
 (0)