Skip to content

Commit af44482

Browse files
Merge branch 'main' into 6.0
2 parents 1f4a6af + 7d56732 commit af44482

File tree

23 files changed

+232
-118
lines changed

23 files changed

+232
-118
lines changed

.github/workflows/integration.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: "Integration"
33
on:
44
push:
55
branches:
6-
- "main"
6+
- "*"
77
pull_request:
88

99
jobs:
@@ -12,10 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest]
15-
php: ['7.3', '7.4', '8.0']
16-
include:
17-
- php: "8.0"
18-
composeroptions: "--ignore-platform-req=php"
15+
php: ['7.3', '7.4', '8.0', '8.1']
1916
steps:
2017
- uses: actions/checkout@master
2118

@@ -29,6 +26,9 @@ jobs:
2926
- name: PHP Version
3027
run: php -v
3128

29+
- name : Install tooling
30+
run : GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} phive --no-progress --home ./.phive install --force-accept-unsigned --trust-gpg-keys 4AA394086372C20A,31C7E470E2138192,8E730BA25823D8B5,CF1A108D0E7AE720,2A8299CE842DD38C,661E97400F658E25
31+
3232
- name: Update composer
3333
run: composer self-update
3434

@@ -38,9 +38,6 @@ jobs:
3838
- name: Install dependencies
3939
run: composer install --prefer-dist --no-progress --no-suggest ${{ matrix.composeroptions }}
4040

41-
- name: Install tooling
42-
run: GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} phive --no-progress --home ./.phive install --force-accept-unsigned --trust-gpg-keys 4AA394086372C20A,31C7E470E2138192,8E730BA25823D8B5,CF1A108D0E7AE720,2A8299CE842DD38C
43-
4441
- name: Execute unit tests
4542
run: tools/phpunit --configuration=phpunit.xml
4643

build.xml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,14 @@
135135
</fileset>
136136
</copy>
137137

138-
<!-- AMAZON AWS -->
138+
<!-- SYMFONY -->
139+
<copy todir="${basedir}/build/phar/lib/symfony/">
140+
<fileset dir="${basedir}/vendor/symfony/">
141+
<include name="**/*.php"/>
142+
</fileset>
143+
</copy>
144+
145+
<!-- AMAZON AWS -->
139146
<copy file="${basedir}/vendor/aws/aws-sdk-php/LICENSE" tofile="${basedir}/build/phar/lib/aws-sdk/LICENSE"/>
140147
<copy todir="${basedir}/build/phar/lib/aws-sdk">
141148
<fileset dir="${basedir}/vendor/aws/aws-sdk-php/src">
@@ -450,16 +457,6 @@
450457
</fileset>
451458
</copy>
452459

453-
<!-- Symfony libs -->
454-
<copy file="${basedir}/vendor/symfony/options-resolver/LICENSE"
455-
tofile="${basedir}/build/phar/lib/symfony/options-resolver/LICENSE"/>
456-
<copy todir="${basedir}/build/phar/lib/symfony/options-resolver">
457-
<fileset dir="${basedir}/vendor/symfony/options-resolver">
458-
<include name="**/*.php"/>
459-
<exclude name="**/Test*"/>
460-
</fileset>
461-
</copy>
462-
463460
<!-- PHP-HTTP -->
464461
<copy file="${basedir}/vendor/php-http/httplug/LICENSE"
465462
tofile="${basedir}/build/phar/lib/php-http/httplug/LICENSE"/>

build/phar-autoload.php.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ if ($execute) {
4848
// dropbox collection helper
4949
require __PHPBU_PHAR_ROOT__ . '/lib/tightenco/Collect/Support/helpers.php';
5050
//require __PHPBU_PHAR_ROOT__ . '/lib/tightenco/Collect/Support/alias.php';
51-
51+
// load the symfony polyfills
52+
require __PHPBU_PHAR_ROOT__ . '/lib/symfony/polyfill-ctype/bootstrap.php';
53+
require __PHPBU_PHAR_ROOT__ . '/lib/symfony/polyfill-mbstring/bootstrap.php';
54+
require __PHPBU_PHAR_ROOT__ . '/lib/symfony/polyfill-php80/bootstrap.php';
55+
5256
phpbu\App\Cmd::main();
5357
}
5458

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"require-dev": {
5656
"sebastianfeldmann/git": "^3.2",
5757
"sebastianfeldmann/ftp": "^0.9",
58-
"guzzlehttp/guzzle": "^5.3.3|^6.2.1|^7.0.0",
58+
"guzzlehttp/guzzle": "^5.3.4|^6.5.8|^7.5.0",
5959
"aws/aws-sdk-php": "^3.10",
6060
"kunalvarma05/dropbox-php-sdk": "^0.2",
6161
"phpseclib/phpseclib": "^2.0",
@@ -65,7 +65,6 @@
6565
"php-opencloud/openstack": "^3.0",
6666
"arhitector/yandex": "^2.0",
6767
"microsoft/azure-storage-blob": "^1.4",
68-
"captainhook/captainhook": "^5.0",
6968
"phpmailer/phpmailer": "^6.0"
7069
},
7170
"suggest": {
@@ -91,7 +90,7 @@
9190
}
9291
},
9392
"scripts": {
94-
"post-autoload-dump": "vendor/bin/captainhook install -f -s",
93+
"post-autoload-dump": "tools/captainhook install -f -s",
9594
"setup": "phive install",
9695
"test": "tools/phpunit",
9796
"analyse": "tools/phpstan analyse",

phive.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpunit" version="^9.4.3" location="./tools/phpunit" copy="true" installed="9.5.19"/>
3+
<phar name="captainhook" version="^5.10.0" location="./tools/captainhook" copy="true" installed="5.10.11"/>
4+
<phar name="phpunit" version="^9.4.3" location="./tools/phpunit" copy="true" installed="9.5.21"/>
45
<phar name="phpab" version="^1.20.0" location="./tools/phpab" copy="true" installed="1.27.1"/>
5-
<phar name="phpcs" version="^3.5.2" location="./tools/phpcs" copy="true" installed="3.6.2"/>
6+
<phar name="phpcs" version="^3.5.2" location="./tools/phpcs" copy="true" installed="3.7.1"/>
67
<phar name="phpstan" version="^0.12.2" location="./tools/phpstan" copy="true" installed="0.12.99"/>
78
</phive>

phpbu.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
<xs:attribute name="bootstrap" type="xs:anyURI"/>
123123
<xs:attribute name="verbose" type="xs:boolean" default="false"/>
124124
<xs:attribute name="colors" type="xs:boolean" default="false"/>
125+
<xs:attribute name="debug" type="xs:boolean" default="false"/>
125126
</xs:attributeGroup>
126127

127128
<xs:group name="configGroup">

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)

src/Backup/Source/Tar.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,6 @@ protected function setupPath(array $conf)
224224
throw new Exception('path option is mandatory');
225225
}
226226
$this->path = Util\Path::toAbsolutePath($path, Configuration::getWorkingDirectory());
227-
if (!file_exists($this->path)) {
228-
throw new Exception('could not find directory to compress');
229-
}
230227
}
231228

232229
/**
@@ -329,10 +326,14 @@ private function handleIncrementalBackup(Executable\Tar $executable): void
329326
*
330327
* @throws \phpbu\App\Exception
331328
*/
332-
private function validatePath()
329+
private function validatePath(): void
333330
{
331+
if (!file_exists($this->path)) {
332+
throw new Exception(sprintf('Could not find directory to compress at "%s".', $this->path));
333+
}
334+
334335
if (!is_dir($this->path)) {
335-
throw new Exception('path to compress has to be a directory');
336+
throw new Exception(sprintf('Cannot compress at path "%s": not a directory.', $this->path));
336337
}
337338
}
338339

src/Backup/Sync/Sftp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public function setup(array $config)
6363
{
6464
// make sure either password or private key is configured
6565
if (!Util\Arr::isSetAndNotEmptyString($config, 'password')
66-
&& !Util\Arr::isSetAndNotEmptyString($config, 'private_key')) {
67-
throw new Exception('\'password\' or \'private_key\' must be presented');
66+
&& !Util\Arr::isSetAndNotEmptyString($config, 'key')) {
67+
throw new Exception('\'password\' or \'key\' must be presented');
6868
}
6969
parent::setup($config);
7070

0 commit comments

Comments
 (0)