Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
57.14% covered (warning)
57.14%
4 / 7
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
PreparedEdit
57.14% covered (warning)
57.14%
4 / 7
50.00% covered (danger)
50.00%
1 / 2
5.26
0.00% covered (danger)
0.00%
0 / 1
 getOutput
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 __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        $this->canonicalOutput ??= ( $this->parserOutputCallback )();
83        // @phan-suppress-next-line PhanTypeMismatchReturnNullable
84        return $this->canonicalOutput;
85    }
86
87    /**
88     * Fetch the ParserOutput via a lazy-loaded callback (for backwards compatibility).
89     *
90     * @deprecated since 1.33
91     * @param string $name
92     * @return mixed
93     */
94    public function __get( $name ) {
95        if ( $name === 'output' ) {
96            return $this->getOutput();
97        } elseif ( $name === 'timestamp' ) {
98            return $this->getOutput()->getCacheTime();
99        }
100
101        throw new RuntimeException( "Undefined field $name." );
102    }
103}