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

ClearOAuthDataTask::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 15
ccs 0
cts 10
cp 0
crap 6
rs 9.7666
c 0
b 0
f 0
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
}