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