From b605d18b2422108f1eef6abd1a250f46ed8b06de Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Thu, 1 Apr 2021 04:47:14 +0000 Subject: [PATCH] Use Content::preloadTransform to transform preload text --- Preloader.class.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Preloader.class.php b/Preloader.class.php index 1cf58c1..c8370dc 100644 --- a/Preloader.class.php +++ b/Preloader.class.php @@ -41,21 +41,11 @@ class Preloader { if ( $title && $title->exists() ) { $revision = Revision::newFromTitle( $title ); $content = $revision->getContent(); - $text = ContentHandler::getContentText( $content ); - return self::transform( $text ); + $parserOptions = ParserOptions::newFromUser( $wgUser ); + $transformed = $content->preloadTransform( $title, $parserOptions ); + return ContentHandler::getContentText( $transformed ); } else { return false; } } - - /** - * Remove sections from the text and trim whitespace - * - * @param $text - * @return string - */ - static function transform( $text ) { - $text = trim( preg_replace( '/<\/?includeonly>/s', '', $text ) ); - return trim( preg_replace( '/.*<\/noinclude>/s', '', $text ) ); - } -} \ No newline at end of file +}