Index: trunk/extensions/Wikilog/Wikilog.php |
— | — | @@ -82,6 +82,7 @@ |
83 | 83 | // WikilogParser.php |
84 | 84 | 'WikilogParser' => $dir . 'WikilogParser.php', |
85 | 85 | 'WikilogParserOutput' => $dir . 'WikilogParser.php', |
| 86 | + 'WikilogParserCache' => $dir . 'WikilogParser.php', |
86 | 87 | |
87 | 88 | // WikilogItemPager.php |
88 | 89 | 'WikilogItemPager' => $dir . 'WikilogItemPager.php', |
Index: trunk/extensions/Wikilog/TODO |
— | — | @@ -24,3 +24,6 @@ |
25 | 25 | * Remove Mw1.16 compatibility boilerplate in: |
26 | 26 | - WikilogComment::getCommentArticleTitle() (GAID_FOR_UPDATE). |
27 | 27 | - WikilogCommentsPage::setCommentApproval() (GAID_FOR_UPDATE). |
| 28 | +* Remove deprecated WikilogParserCache: |
| 29 | + - WikilogParserCache class definition in WikilogParser.php. |
| 30 | + - WikilogUtils::parsedArticle() in WikilogUtils.php. |
Index: trunk/extensions/Wikilog/WikilogParser.php |
— | — | @@ -616,3 +616,36 @@ |
617 | 617 | public function getTags() { return $this->mTags; } |
618 | 618 | } |
619 | 619 | |
| 620 | +/** |
| 621 | + * Since wikilog parses articles with specific options in order to be |
| 622 | + * rendered in feeds, it is necessary to store these parsed outputs in |
| 623 | + * the cache separately. This derived class from ParserCache overloads the |
| 624 | + * getKey() function in order to provide a specific namespace for this |
| 625 | + * purpose. |
| 626 | + * |
| 627 | + * @deprecated In MediaWiki 1.17, in favor of $parserOpt->addExtraKey(). |
| 628 | + * @todo (In Wikilog 1.3.x) Remove this class. |
| 629 | + */ |
| 630 | +class WikilogParserCache |
| 631 | + extends ParserCache |
| 632 | +{ |
| 633 | + public static function &singleton() { |
| 634 | + static $instance; |
| 635 | + if ( !isset( $instance ) ) { |
| 636 | + global $parserMemc; |
| 637 | + $instance = new WikilogParserCache( $parserMemc ); |
| 638 | + } |
| 639 | + return $instance; |
| 640 | + } |
| 641 | + |
| 642 | + public function getKey( &$article, $popts ) { |
| 643 | + if ( $popts instanceof User ) // API change in MediaWiki 1.15. |
| 644 | + $popts = ParserOptions::newFromUser( $popts ); |
| 645 | + |
| 646 | + $user = $popts->mUser; |
| 647 | + $pageid = intval( $article->getID() ); |
| 648 | + $hash = $user->getPageRenderingHash(); |
| 649 | + $key = wfMemcKey( 'wlcache', 'idhash', "$pageid-$hash" ); |
| 650 | + return $key; |
| 651 | + } |
| 652 | +} |
Index: trunk/extensions/Wikilog/WikilogUtils.php |
— | — | @@ -59,6 +59,9 @@ |
60 | 60 | * parser that we could mess up without interfering with normal page |
61 | 61 | * rendering, and we can't create a new instance because of too many |
62 | 62 | * broken extensions around. Check self::parserSanityCheck(). |
| 63 | + * |
| 64 | + * @todo (In Wikilog 1.3.x) Remove deprecated WikilogParserCache |
| 65 | + * in favor of ParserOptions::addExtraKey(). |
63 | 66 | */ |
64 | 67 | public static function parsedArticle( Title $title, $feed = false ) { |
65 | 68 | global $wgWikilogCloneParser; |
— | — | @@ -73,20 +76,28 @@ |
74 | 77 | $useParserCache = $wgEnableParserCache && |
75 | 78 | intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 && |
76 | 79 | $article->exists(); |
| 80 | + $parserCacheClass = "ParserCache"; |
77 | 81 | |
78 | 82 | # Parser options. |
79 | 83 | $parserOpt = ParserOptions::newFromUser( $wgUser ); |
80 | 84 | $parserOpt->setTidy( true ); |
81 | 85 | if ( $feed ) { |
82 | 86 | $parserOpt->setEditSection( false ); |
83 | | - $parserOpt->addExtraKey( "WikilogFeed" ); |
| 87 | + |
| 88 | + # NOTE (Mw1.16- COMPAT) ParserOptions::addExtraKey() added in |
| 89 | + # MediaWiki 1.17 (r70822) makes WikilogParserCache obsolete. |
| 90 | + if ( method_exists( $parserOpt, 'addExtraKey' ) ) { |
| 91 | + $parserOpt->addExtraKey( "WikilogFeed" ); |
| 92 | + } else { |
| 93 | + $parserCacheClass = "WikilogParserCache"; |
| 94 | + } |
84 | 95 | } else { |
85 | 96 | $parserOpt->enableLimitReport(); |
86 | 97 | } |
87 | 98 | |
88 | 99 | if ( $useParserCache ) { |
89 | | - # Select parser cache according to the $feed flag. |
90 | | - $parserCache = ParserCache::singleton(); |
| 100 | + # Get the parser cache instance. |
| 101 | + $parserCache = $parserCacheClass::singleton(); |
91 | 102 | |
92 | 103 | # Look for the parsed article output in the parser cache. |
93 | 104 | $parserOutput = $parserCache->get( $article, $parserOpt ); |