Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
62.50% covered (warning)
62.50%
5 / 8
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
PreparedEdit
62.50% covered (warning)
62.50%
5 / 8
50.00% covered (danger)
50.00%
1 / 2
6.32
0.00% covered (danger)
0.00%
0 / 1
 getOutput
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 __get
40.00% covered (danger)
40.00%
2 / 5
0.00% covered (danger)
0.00%
0 / 1
4.94
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 */
6
7namespace MediaWiki\Edit;
8
9use MediaWiki\Content\Content;
10use MediaWiki\Parser\ParserOptions;
11use MediaWiki\Parser\ParserOutput;
12use RuntimeException;
13
14/**
15 * Represents information returned by WikiPage::prepareContentForEdit()
16 *
17 * @deprecated since 1.32; Since 1.37, use PreparedUpdate instead.
18 *
19 * @since 1.30
20 */
21class PreparedEdit {
22    /**
23     * Revision ID
24     *
25     * @var int|null
26     */
27    public $revid;
28
29    /**
30     * Content after going through pre-save transform
31     *
32     * @var Content|null
33     */
34    public $pstContent;
35
36    /**
37     * Content format
38     *
39     * @var string
40     */
41    public $format;
42
43    /**
44     * Parser options used to get parser output
45     *
46     * @var ParserOptions
47     */
48    public $popts;
49
50    /**
51     * Parser output
52     *
53     * @var ParserOutput|null
54     */
55    private $canonicalOutput;
56
57    /**
58     * Content that is being saved (before PST)
59     *
60     * @var Content
61     */
62    public $newContent;
63
64    /**
65     * Current content of the page, if any
66     *
67     * @var Content|null
68     */
69    public $oldContent;
70
71    /**
72     * Lazy-loading callback to get canonical ParserOutput object
73     *
74     * @var callable
75     */
76    public $parserOutputCallback;
77
78    /**
79     * @return ParserOutput Canonical parser output
80     */
81    public function getOutput() {
82        if ( !$this->canonicalOutput ) {
83            $this->canonicalOutput = ( $this->parserOutputCallback )();
84        }
85
86        return $this->canonicalOutput;
87    }
88
89    /**
90     * Fetch the ParserOutput via a lazy-loaded callback (for backwards compatibility).
91     *
92     * @deprecated since 1.33
93     * @param string $name
94     * @return mixed
95     */
96    public function __get( $name ) {
97        if ( $name === 'output' ) {
98            return $this->getOutput();
99        } elseif ( $name === 'timestamp' ) {
100            return $this->getOutput()->getCacheTime();
101        }
102
103        throw new RuntimeException( "Undefined field $name." );
104    }
105}