Tweaks to RELEASE-NOTES needed before tagging 1.34.0-rc.0
[lhc/web/wiklou.git] / includes / edit / PreparedEdit.php
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 Content;
24 use ParserOptions;
25 use RuntimeException;
26 use ParserOutput;
27
28 /**
29 * Represents information returned by WikiPage::prepareContentForEdit()
30 *
31 * @deprecated since 1.32, use DerivedPageDataUpdater instead.
32 *
33 * @since 1.30
34 */
35 class PreparedEdit {
36 /**
37 * Time this prepared edit was made
38 *
39 * @var string
40 */
41 public $timestamp;
42
43 /**
44 * Revision ID
45 *
46 * @var int|null
47 */
48 public $revid;
49
50 /**
51 * Content after going through pre-save transform
52 *
53 * @var Content|null
54 */
55 public $pstContent;
56
57 /**
58 * Content format
59 *
60 * @var string
61 */
62 public $format;
63
64 /**
65 * Parser options used to get parser output
66 *
67 * @var ParserOptions
68 */
69 public $popts;
70
71 /**
72 * Parser output
73 *
74 * @var ParserOutput|null
75 */
76 private $canonicalOutput;
77
78 /**
79 * Content that is being saved (before PST)
80 *
81 * @var Content
82 */
83 public $newContent;
84
85 /**
86 * Current content of the page, if any
87 *
88 * @var Content|null
89 */
90 public $oldContent;
91
92 /**
93 * Lazy-loading callback to get canonical ParserOutput object
94 *
95 * @var callable
96 */
97 public $parserOutputCallback;
98
99 /**
100 * @return ParserOutput Canonical parser output
101 */
102 public function getOutput() {
103 if ( !$this->canonicalOutput ) {
104 $this->canonicalOutput = call_user_func( $this->parserOutputCallback );
105 }
106
107 return $this->canonicalOutput;
108 }
109
110 /**
111 * Fetch the ParserOutput via a lazy-loaded callback (for backwards compatibility).
112 *
113 * @deprecated since 1.33
114 * @param string $name
115 * @return mixed
116 */
117 function __get( $name ) {
118 if ( $name === 'output' ) {
119 return $this->getOutput();
120 }
121
122 throw new RuntimeException( "Undefined field $name." );
123 }
124 }