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