+ $options = ParserOptions::newFromContext( $this->getContext() );
+
+ if ( $params['includecomments'] ) {
+ $options->setRemoveComments( false );
+ }
+
+ if ( $params['generatexml'] ) {
+ $wgParser->startExternalParse( $title_obj, $options, OT_PREPROCESS );
+ $dom = $wgParser->preprocessToDom( $params['text'] );
+ if ( is_callable( array( $dom, 'saveXML' ) ) ) {
+ $xml = $dom->saveXML();
+ } else {
+ $xml = $dom->__toString();
+ }
+ $xml_result = array();
+ $result->setContent( $xml_result, $xml );
+ $result->addValue( null, 'parsetree', $xml_result );
+ }
+ $retval = $wgParser->preprocess( $params['text'], $title_obj, $options );