Failed Conditions
Push — newinternal ( b66232...216d62 )
by Simon
16:33 queued 06:35
created

ClearOAuthDataTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 15 2
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca\ConsoleTasks;
10
11
use Waca\Helpers\OAuthUserHelper;
12
use Waca\Helpers\SearchHelpers\UserSearchHelper;
13
use Waca\Tasks\ConsoleTaskBase;
14
15
class ClearOAuthDataTask extends ConsoleTaskBase
16
{
17
    public function execute()
18
    {
19
        $database = $this->getDatabase();
20
21
        $users = UserSearchHelper::get($database)->inIds(
22
            $database->query('SELECT user FROM oauthtoken WHERE type = \'access\'')->fetchColumn());
23
24
        foreach ($users as $u){
0 ignored issues
show
Bug introduced by
The expression $users of type object<Waca\Helpers\Sear...lpers\UserSearchHelper> is not traversable.
Loading history...
25
            $oauth = new OAuthUserHelper($u, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
26
            $oauth->detach();
27
        }
28
29
        $database->exec('DELETE FROM oauthtoken');
30
        $database->exec('DELETE FROM oauthidentity');
31
    }
32
}