Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
UnarchiveElectionJob
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 run
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace MediaWiki\Extension\SecurePoll\Jobs;
4
5use Job;
6use MediaWiki\Extension\SecurePoll\Context;
7
8/**
9 * Unarchive an election
10 */
11class UnarchiveElectionJob extends Job {
12    /**
13     * @inheritDoc
14     */
15    public function __construct( $title, $params ) {
16        parent::__construct( 'securePollUnarchiveElection', $title, $params );
17    }
18
19    /**
20     * @return bool
21     */
22    public function run() {
23        $electionId = $this->params['electionId'];
24        $context = new Context();
25        $dbw = $context->getDB( DB_PRIMARY );
26
27        $isArchived = $dbw->newSelectQueryBuilder()
28            ->select( 'pr_value' )
29            ->from( 'securepoll_properties' )
30            ->where( [
31                'pr_entity' => $electionId,
32                'pr_key' => 'is-archived',
33            ] )
34            ->caller( __METHOD__ )
35            ->fetchField();
36        if ( $isArchived ) {
37            $dbw->newDeleteQueryBuilder()
38                ->deleteFrom( 'securepoll_properties' )
39                ->where( [
40                    'pr_entity' => $electionId,
41                    'pr_key' => 'is-archived',
42                ] )
43                ->caller( __METHOD__ )
44                ->execute();
45        }
46        return true;
47    }
48}