Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
McrRestoreAction
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 5
72
0.00% covered (danger)
0.00%
0 / 1
 getName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDescription
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 initFromParameters
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
20
 addStatePropagationFields
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 alterForm
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Temporary action for restoring multi-content revisions
4 * @file
5 * @ingroup Actions
6 */
7
8use MediaWiki\HTMLForm\HTMLForm;
9
10/**
11 * Temporary action for restoring multi-content revisions.
12 *
13 * This is intended to go away when real MCR support is added to EditPage and
14 * the standard revert-by-edit behavior can be implemented there instead.
15 *
16 * @ingroup Actions
17 * @since 1.32
18 */
19class McrRestoreAction extends McrUndoAction {
20
21    public function getName() {
22        return 'mcrrestore';
23    }
24
25    public function getDescription() {
26        return '';
27    }
28
29    protected function initFromParameters() {
30        $curRev = $this->getWikiPage()->getRevisionRecord();
31        if ( !$curRev ) {
32            throw new ErrorPageError( 'mcrundofailed', 'nopagetext' );
33        }
34        $this->curRev = $curRev;
35        $this->cur = $this->getRequest()->getInt( 'cur', $this->curRev->getId() );
36
37        $this->undo = $this->cur;
38        $this->undoafter = $this->getRequest()->getInt( 'restore' );
39
40        if ( $this->undo == 0 || $this->undoafter == 0 ) {
41            throw new ErrorPageError( 'mcrundofailed', 'mcrundo-missingparam' );
42        }
43    }
44
45    protected function addStatePropagationFields( HTMLForm $form ) {
46        $form->addHiddenField( 'restore', $this->undoafter );
47        $form->addHiddenField( 'cur', $this->curRev->getId() );
48    }
49
50    protected function alterForm( HTMLForm $form ) {
51        parent::alterForm( $form );
52
53        $form->setWrapperLegendMsg( 'confirm-mcrrestore-title' );
54    }
55
56}