Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
RevDelArchivedRevisionItem | |
0.00% |
0 / 14 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getIdField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setBits | |
0.00% |
0 / 10 |
|
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 | |
22 | use Wikimedia\Rdbms\IConnectionProvider; |
23 | |
24 | /** |
25 | * Item class for a archive table row by ar_rev_id -- actually |
26 | * used via RevDelRevisionList. |
27 | */ |
28 | class RevDelArchivedRevisionItem extends RevDelArchiveItem { |
29 | |
30 | /** @var IConnectionProvider */ |
31 | protected IConnectionProvider $connectionProvider; |
32 | |
33 | /** |
34 | * @param RevisionListBase $list |
35 | * @param stdClass $row |
36 | * @param IConnectionProvider $connectionProvider |
37 | */ |
38 | public function __construct( RevisionListBase $list, stdClass $row, IConnectionProvider $connectionProvider ) { |
39 | $this->connectionProvider = $connectionProvider; |
40 | parent::__construct( $list, $row ); |
41 | } |
42 | |
43 | /** |
44 | * @return string |
45 | */ |
46 | public function getIdField(): string { |
47 | return 'ar_rev_id'; |
48 | } |
49 | |
50 | /** |
51 | * @return int |
52 | */ |
53 | public function getId(): int { |
54 | return $this->getRevisionRecord()->getId(); |
55 | } |
56 | |
57 | /** |
58 | * @param int $bits |
59 | * @return bool |
60 | */ |
61 | public function setBits( $bits ): bool { |
62 | $dbw = $this->connectionProvider->getPrimaryDatabase(); |
63 | $dbw->newUpdateQueryBuilder() |
64 | ->update( 'archive' ) |
65 | ->set( [ 'ar_deleted' => $bits ] ) |
66 | ->where( [ |
67 | 'ar_rev_id' => $this->row->ar_rev_id, |
68 | 'ar_deleted' => $this->getBits(), |
69 | ] ) |
70 | ->caller( __METHOD__ )->execute(); |
71 | |
72 | return (bool)$dbw->affectedRows(); |
73 | } |
74 | } |