Index: trunk/extensions/Wikilog/WikilogUtils.php |
— | — | @@ -41,6 +41,23 @@ |
42 | 42 | * @param $title Article title object. |
43 | 43 | * @param $feed Whether the result should be part of a feed. |
44 | 44 | * @return Two-element array containing the article and its parser output. |
| 45 | + * |
| 46 | + * @note Mw1.16+ provides Article::getParserOptions() and |
| 47 | + * Article::getParserOutput(), that could be used here in the future. |
| 48 | + * The problem is that getParserOutput() uses ParserCache exclusively, |
| 49 | + * which means that only ParserOptions control the key used to store |
| 50 | + * the output in the cache and there is no hook yet in |
| 51 | + * ParserCache::getKey() to set these extra bits (and the |
| 52 | + * 'PageRenderingCache' hook is not useful here, it is in the wrong |
| 53 | + * place without access to the parser options). This is certainly |
| 54 | + * something that should be fixed in the future. FIXME |
| 55 | + * |
| 56 | + * @note This function makes a clone of the parser if |
| 57 | + * $wgWikilogCloneParser is set, but cloning the parser is not |
| 58 | + * officially supported. The problem here is that we need a different |
| 59 | + * parser that we could mess up without interfering with normal page |
| 60 | + * rendering, and we can't create a new instance because of too many |
| 61 | + * broken extensions around. Check self::parserSanityCheck(). |
45 | 62 | */ |
46 | 63 | public static function parsedArticle( Title $title, $feed = false ) { |
47 | 64 | global $wgWikilogCloneParser; |
— | — | @@ -52,14 +69,27 @@ |
53 | 70 | $article = new Article( $title ); |
54 | 71 | |
55 | 72 | # First try the parser cache. |
56 | | - if ( $wgEnableParserCache ) { |
| 73 | + $useParserCache = $wgEnableParserCache && |
| 74 | + intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 && |
| 75 | + $article->exists(); |
| 76 | + |
| 77 | + # Parser options. |
| 78 | + $parserOpt = ParserOptions::newFromUser( $wgUser ); |
| 79 | + $parserOpt->setTidy( true ); |
| 80 | + if ( $feed ) { |
| 81 | + $parserOpt->setEditSection( false ); |
| 82 | + } else { |
| 83 | + $parserOpt->enableLimitReport(); |
| 84 | + } |
| 85 | + |
| 86 | + if ( $useParserCache ) { |
57 | 87 | # Select parser cache according to the $feed flag. |
58 | 88 | $parserCache = $feed |
59 | 89 | ? WikilogParserCache::singleton() |
60 | 90 | : ParserCache::singleton(); |
61 | 91 | |
62 | 92 | # Look for the parsed article output in the parser cache. |
63 | | - $parserOutput = $parserCache->get( $article, $wgUser ); |
| 93 | + $parserOutput = $parserCache->get( $article, $parserOpt ); |
64 | 94 | |
65 | 95 | # On success, return the object retrieved from the cache. |
66 | 96 | if ( $parserOutput ) { |
— | — | @@ -67,17 +97,10 @@ |
68 | 98 | } |
69 | 99 | } |
70 | 100 | |
71 | | - # Parser options. |
72 | | - $parserOpt = ParserOptions::newFromUser( $wgUser ); |
73 | | - $parserOpt->setTidy( true ); |
74 | | - |
75 | 101 | # Enable some feed-specific behavior. |
76 | 102 | if ( $feed ) { |
77 | 103 | $saveFeedParse = WikilogParser::enableFeedParsing(); |
78 | 104 | $saveExpUrls = WikilogParser::expandLocalUrls(); |
79 | | - $parserOpt->setEditSection( false ); |
80 | | - } else { |
81 | | - $parserOpt->enableLimitReport(); |
82 | 105 | } |
83 | 106 | |
84 | 107 | # Get a parser instance, if not already cached. |
— | — | @@ -99,8 +122,8 @@ |
100 | 123 | $parserOutput = $parser->parse( $arttext, $title, $parserOpt ); |
101 | 124 | |
102 | 125 | # Save in parser cache. |
103 | | - if ( $wgEnableParserCache && $parserOutput->getCacheTime() != -1 ) { |
104 | | - $parserCache->save( $parserOutput, $article, $wgUser ); |
| 126 | + if ( $useParserCache && $parserOutput->getCacheTime() != -1 ) { |
| 127 | + $parserCache->save( $parserOutput, $article, $parserOpt ); |
105 | 128 | } |
106 | 129 | |
107 | 130 | # Restore default behavior. |
Index: trunk/extensions/Wikilog/WikilogComment.php |
— | — | @@ -608,8 +608,13 @@ |
609 | 609 | $params = $this->getCommentMsgParams( $comment ); |
610 | 610 | $html = $this->formatCommentHeader( $comment, $params ); |
611 | 611 | |
612 | | - $text = $wgOut->parse( $comment->getText() ); // TODO: Optimize this. |
613 | | - $html .= WikilogUtils::wrapDiv( 'wl-comment-text', $text ); |
| 612 | + if ( $comment->mCommentRev ) { |
| 613 | + list( $article, $parserOutput ) = WikilogUtils::parsedArticle( $comment->mCommentTitle ); |
| 614 | + $text = $parserOutput->getText(); |
| 615 | + if ( $text ) { |
| 616 | + $html .= WikilogUtils::wrapDiv( 'wl-comment-text', $text ); |
| 617 | + } |
| 618 | + } |
614 | 619 | |
615 | 620 | $html .= $this->formatCommentFooter( $comment, $params ); |
616 | 621 | $html .= $this->getCommentToolLinks( $comment ); |