Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
RevDelArchivedRevisionItem
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 4
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getIdField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setBits
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup RevisionDelete
20 */
21
22use MediaWiki\RevisionList\RevisionListBase;
23use Wikimedia\Rdbms\IConnectionProvider;
24
25/**
26 * Item class for a archive table row by ar_rev_id -- actually
27 * used via RevDelRevisionList.
28 */
29class RevDelArchivedRevisionItem extends RevDelArchiveItem {
30
31    protected IConnectionProvider $dbProvider;
32
33    /**
34     * @param RevisionListBase $list
35     * @param stdClass $row
36     * @param IConnectionProvider $dbProvider
37     */
38    public function __construct( RevisionListBase $list, stdClass $row, IConnectionProvider $dbProvider ) {
39        $this->dbProvider = $dbProvider;
40        parent::__construct( $list, $row );
41    }
42
43    public function getIdField(): string {
44        return 'ar_rev_id';
45    }
46
47    public function getId(): int {
48        return $this->getRevisionRecord()->getId();
49    }
50
51    /**
52     * @param int $bits
53     * @return bool
54     */
55    public function setBits( $bits ): bool {
56        $dbw = $this->dbProvider->getPrimaryDatabase();
57        $dbw->newUpdateQueryBuilder()
58            ->update( 'archive' )
59            ->set( [ 'ar_deleted' => $bits ] )
60            ->where( [
61                'ar_rev_id' => $this->row->ar_rev_id,
62                'ar_deleted' => $this->getBits(),
63            ] )
64            ->caller( __METHOD__ )->execute();
65
66        return (bool)$dbw->affectedRows();
67    }
68}