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

includes/ConsoleTasks/ClearOAuthDataTask.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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
}