X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fedit%2FPreparedEdit.php;h=88eae36414c7d745bdde1bf2ce6e2f44429d4869;hb=1139a9af6ae8fa18db9645e4309c5b1bd40d9c8b;hp=70073161b2d8949d2ca24cacc360f0aeb28f66b5;hpb=f459a71f75941a83335d6d63ee12079a4b586793;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/edit/PreparedEdit.php b/includes/edit/PreparedEdit.php index 70073161b2..88eae36414 100644 --- a/includes/edit/PreparedEdit.php +++ b/includes/edit/PreparedEdit.php @@ -22,6 +22,7 @@ namespace MediaWiki\Edit; use Content; use ParserOptions; +use RuntimeException; use ParserOutput; /** @@ -32,7 +33,6 @@ use ParserOutput; * @since 1.30 */ class PreparedEdit { - /** * Time this prepared edit was made * @@ -73,7 +73,7 @@ class PreparedEdit { * * @var ParserOutput|null */ - public $output; + private $canonicalOutput; /** * Content that is being saved (before PST) @@ -89,4 +89,36 @@ class PreparedEdit { */ public $oldContent; + /** + * Lazy-loading callback to get canonical ParserOutput object + * + * @var callable + */ + public $parserOutputCallback; + + /** + * @return ParserOutput Canonical parser output + */ + public function getOutput() { + if ( !$this->canonicalOutput ) { + $this->canonicalOutput = call_user_func( $this->parserOutputCallback ); + } + + return $this->canonicalOutput; + } + + /** + * Fetch the ParserOutput via a lazy-loaded callback (for backwards compatibility). + * + * @deprecated since 1.33 + * @param string $name + * @return mixed + */ + function __get( $name ) { + if ( $name === 'output' ) { + return $this->getOutput(); + } + + throw new RuntimeException( "Undefined field $name." ); + } }