Skip to content

Commit 6c3888b

Browse files
committed
Merge branch 'develop'
* develop: Fix code style issues. Fix loadCommands trait. Update documentation. Remove drupal specific settings. Move them to robo-digipolis-drupal8. Fix indentation. Fix code style issues. Fix code style issues. Fix code style issues. Improve output.
2 parents c93a0b7 + 1638d80 commit 6c3888b

21 files changed

+175
-139
lines changed

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ engines:
2323
config:
2424
languages:
2525
php:
26-
mass_threshold: 50
26+
mass_threshold: 80
2727
fixme:
2828
enabled: true
2929
markdownlint:

README.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,7 @@ directory of the local filesystem.
284284
Path to a PHP file containing database config as documented at
285285
<https://github.com/backup-manager/backup-manager>. Defaults to a database with
286286
the name of the current working directory as database name, on `localhost` port
287-
`3306`, user `root` and an empty password. If the `--drupal` option is given and
288-
this option is skipped, the database config will be parsed from Drupal's
289-
`settings.php`.
287+
`3306`, user `root` and an empty password.
290288

291289
##### --compression, -c
292290

@@ -301,11 +299,6 @@ current working directory.
301299

302300
The destination type (e.g. `local`, `dropbox`, `ftp`). Defaults to `local`.
303301

304-
##### --drupal
305-
306-
Wether or not to parse the database config from Drupal's `settings.php`. See
307-
the documentation for `--database-config`.
308-
309302
### digipolis:database-restore
310303

311304
`vendor/bin/robo digipolis:database-restore [DATABASE] [OPTIONS]`
@@ -330,9 +323,7 @@ directory of the local filesystem.
330323
Path to a PHP file containing database config as documented at
331324
<https://github.com/backup-manager/backup-manager>. Defaults to a database with
332325
the name of the current working directory as database name, on `localhost` port
333-
`3306`, user `root` and an empty password. If the `--drupal` option is given and
334-
this option is skipped, the database config will be parsed from Drupal's
335-
`settings.php`.
326+
`3306`, user `root` and an empty password.
336327

337328
##### --compression, -c
338329

@@ -347,11 +338,6 @@ directory.
347338

348339
The source type (e.g. `local`, `dropbox`, `ftp`). Defaults to `local`.
349340

350-
##### --drupal
351-
352-
Wether or not to parse the database config from Drupal's `settings.php`. See
353-
the documentation for `--database-config`.
354-
355341
### digipolis:push-package
356342

357343
`vendor/bin/robo digipolis:push-package USER HOST PACKAGE [DESTINATION] [OPTIONS]`

src/BackupManager/Compressors/TarCompressor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public function getDecompressCommandLine($outputPath)
3737
. ' --directory=' . escapeshellarg(dirname($outputPath))
3838
. ' --transform=' . escapeshellarg('s,.*,' . $this->getDecompressedPath(basename($outputPath)) . ',')
3939
. ' && rm -rf ' . escapeshellarg($outputPath);
40-
4140
}
4241

4342
/**

src/BackupManager/Databases/MysqlDatabase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public function getDumpCommandLine($outputPath)
7474
*/
7575
public function getRestoreCommandLine($inputPath)
7676
{
77-
return sprintf('mysql --host=%s --port=%s --user=%s --password=%s %s -e "source %s"',
77+
return sprintf(
78+
'mysql --host=%s --port=%s --user=%s --password=%s %s -e "source %s"',
7879
escapeshellarg($this->config['host']),
7980
escapeshellarg($this->config['port']),
8081
escapeshellarg($this->config['user']),

src/ClearOpCache.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function run()
6161
$adapter = new \CacheTool\Adapter\FastCGI($this->host);
6262
break;
6363
}
64+
$this->printTaskInfo(sprintf('Resetting opcache for %s.', $this->environment));
6465
$cachetool = \CacheTool\CacheTool::factory($adapter);
6566
$cachetool->opcache_reset();
6667
return Result::success($this);

src/Commands/DatabaseBackup.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ public function digipolisDatabaseBackup($database = 'default', $opts = [
2222
'compression|c' => 'gzip',
2323
'destination|d' => null,
2424
'destination-type|dtype' => 'local',
25-
'drupal' => false,
2625
])
2726
{
28-
if (is_callable([$this, 'readProperties']))
29-
{
27+
if (is_callable([$this, 'readProperties'])) {
3028
$this->readProperties();
3129
}
3230
$destination = is_null($opts['destination'])

src/Commands/DatabaseRestore.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ public function digipolisDatabaseRestore($database = 'default', $opts = [
2222
'compression|c' => 'gzip',
2323
'source|s' => null,
2424
'source-type|stype' => 'local',
25-
'drupal' => false,
2625
])
2726
{
28-
if (is_callable([$this, 'readProperties']))
29-
{
27+
if (is_callable([$this, 'readProperties'])) {
3028
$this->readProperties();
3129
}
3230
$source = is_null($opts['source'])

src/Commands/loadCommands.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ trait loadCommands
77
use DatabaseBackup, DatabaseRestore {
88
DatabaseBackup::defaultFileSystemConfig insteadof DatabaseRestore;
99
DatabaseBackup::defaultDbConfig insteadof DatabaseRestore;
10-
DatabaseBackup::parseDrupalDbConfig insteadof DatabaseRestore;
1110
DatabaseBackup::createDbTask insteadof DatabaseRestore;
1211
}
1312
use PushPackage;

src/Common/DatabaseCommand.php

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ protected function defaultFileSystemConfig()
1717
];
1818
}
1919

20-
protected function defaultDbConfig($drupal = false)
20+
protected function defaultDbConfig()
2121
{
22-
$dbConfig = [
22+
return [
2323
'default' => [
2424
'type' => 'mysql',
2525
'host' => 'localhost',
@@ -29,54 +29,6 @@ protected function defaultDbConfig($drupal = false)
2929
'database' => dirname(realpath(getcwd())),
3030
],
3131
];
32-
return $drupal
33-
? $this->parseDrupalDbConfig()
34-
: $dbConfig;
35-
}
36-
37-
protected function parseDrupalDbConfig()
38-
{
39-
$webDir = $this->getConfig()->get('digipolis.root.web', false);
40-
if (!$webDir) {
41-
return false;
42-
}
43-
44-
$finder = new \Symfony\Component\Finder\Finder();
45-
$finder->in($webDir . '/sites')->files()->name('settings.php');
46-
foreach ($finder as $settingsFile) {
47-
$site_path = null;
48-
$app_root = null;
49-
include_once $settingsFile->getRealpath();
50-
break;
51-
}
52-
if (!isset($databases['default']['default'])) {
53-
return false;
54-
}
55-
$config = $databases['default']['default'];
56-
return [
57-
'default' => [
58-
'type' => $config['driver'],
59-
'host' => $config['host'],
60-
'port' => isset($config['port']) ? $config['port'] : '3306',
61-
'user' => $config['username'],
62-
'pass' => $config['password'],
63-
'database' => $config['database'],
64-
'structureTables' => [
65-
'batch',
66-
'cache',
67-
'cache_*',
68-
'*_cache',
69-
'*_cache_*',
70-
'flood',
71-
'search_dataset',
72-
'search_index',
73-
'search_total',
74-
'semaphore',
75-
'sessions',
76-
'watchdog',
77-
],
78-
]
79-
];
8032
}
8133

8234
/**
@@ -98,7 +50,7 @@ protected function createDbTask($task, $database, $opts)
9850
: $this->defaultFileSystemConfig();
9951
$dbConfig = $opts['database-config']
10052
?
101-
: $this->defaultDbConfig($opts['drupal']);
53+
: $this->defaultDbConfig();
10254

10355
return $this->{$task}($filesystemConfig, $dbConfig)
10456
->compression($opts['compression'])

src/DatabaseBackup.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,23 @@ public function run()
152152
* The backup manager
153153
* @var \DigipolisGent\Robo\Task\Deploy\BackupManager\Adapter\BackupManagerAdapterInterface
154154
*/
155-
$manager = call_user_func([$this->backupManagerFactory, 'create'], $this->filesystemConfig, $this->dbConfig);
155+
$manager = call_user_func(
156+
[$this->backupManagerFactory, 'create'],
157+
$this->filesystemConfig,
158+
$this->dbConfig
159+
);
156160
if (empty($this->destinations)) {
157161
$this->destination(getcwd());
158162
}
159-
$manager->makeBackup()->run($this->database, $this->destinations, $this->compression);
163+
$this->printTaskInfo(sprintf(
164+
'Creating database backup with %s compression.',
165+
$this->compression
166+
));
167+
$manager->makeBackup()->run(
168+
$this->database,
169+
$this->destinations,
170+
$this->compression
171+
);
160172
} catch (\Exception $e) {
161173
return Result::fromException($this, $e);
162174
}

0 commit comments

Comments
 (0)