Completed
Pull Request — master (#5166)
by Damian
09:53
created

CleanuPTestDatabasesTask::init()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 7
rs 9.4285
cc 3
eloc 4
nc 2
nop 0
1
<?php
2
/**
3
 * Cleans up leftover databases from aborted test executions (starting with ss_tmpdb)
4
 * Task is restricted to users with administrator rights or running through CLI.
5
 *
6
 * @package framework
7
 * @subpackage tasks
8
 */
9
class CleanupTestDatabasesTask extends BuildTask {
10
	protected $title = 'Deletes all temporary test databases';
11
12
	protected $description = 'Cleans up leftover databases from aborted test executions (starting with ss_tmpdb)';
13
14
	public function run($request) {
15
		if(!Permission::check('ADMIN') && !Director::is_cli()) {
16
			$response = Security::permissionFailure($this);
17
			if($response) {
18
				$response->output();
19
			}
20
			die;
0 ignored issues
show
Coding Style Compatibility introduced by
The method run() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
21
		}
22
23
		SapphireTest::delete_all_temp_dbs();
24
	}
25
26
}
27