r74593 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74592‎ | r74593 | r74594 >
Date:13:57, 10 October 2010
Author:platonides
Status:deferred (Comments)
Tags:
Comment:
Remove WikilogParserCache. Use $parserOpt->addExtraKey()
This should allow usage of Article::getParserOptions() as noted in the FIXME.
You may need to create a new Article() and directly access its $mParserOptions
Modified paths:
  • /trunk/extensions/Wikilog/Wikilog.php (modified) (history)
  • /trunk/extensions/Wikilog/WikilogParser.php (modified) (history)
  • /trunk/extensions/Wikilog/WikilogUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikilog/Wikilog.php
@@ -82,7 +82,6 @@
8383 // WikilogParser.php
8484 'WikilogParser' => $dir . 'WikilogParser.php',
8585 'WikilogParserOutput' => $dir . 'WikilogParser.php',
86 - 'WikilogParserCache' => $dir . 'WikilogParser.php',
8786
8887 // WikilogItemPager.php
8988 'WikilogItemPager' => $dir . 'WikilogItemPager.php',
Index: trunk/extensions/Wikilog/WikilogParser.php
@@ -616,33 +616,3 @@
617617 public function getTags() { return $this->mTags; }
618618 }
619619
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 -class WikilogParserCache
628 - extends ParserCache
629 -{
630 - public static function &singleton() {
631 - static $instance;
632 - if ( !isset( $instance ) ) {
633 - global $parserMemc;
634 - $instance = new WikilogParserCache( $parserMemc );
635 - }
636 - return $instance;
637 - }
638 -
639 - public function getKey( &$article, $popts ) {
640 - if ( $popts instanceof User ) // API change in MediaWiki 1.15.
641 - $popts = ParserOptions::newFromUser( $popts );
642 -
643 - $user = $popts->mUser;
644 - $pageid = intval( $article->getID() );
645 - $hash = $user->getPageRenderingHash();
646 - $key = wfMemcKey( 'wlcache', 'idhash', "$pageid-$hash" );
647 - return $key;
648 - }
649 -}
Index: trunk/extensions/Wikilog/WikilogUtils.php
@@ -79,15 +79,14 @@
8080 $parserOpt->setTidy( true );
8181 if ( $feed ) {
8282 $parserOpt->setEditSection( false );
 83+ $parserOpt->addExtraKey( "WikilogFeed" );
8384 } else {
8485 $parserOpt->enableLimitReport();
8586 }
8687
8788 if ( $useParserCache ) {
8889 # Select parser cache according to the $feed flag.
89 - $parserCache = $feed
90 - ? WikilogParserCache::singleton()
91 - : ParserCache::singleton();
 90+ $parserCache = ParserCache::singleton();
9291
9392 # Look for the parsed article output in the parser cache.
9493 $parserOutput = $parserCache->get( $article, $parserOpt );

Follow-up revisions

RevisionCommit summaryAuthorDate
r75183Partially revert r74593 to make it work again with current stable MediaWiki...juliano05:01, 22 October 2010

Comments

#Comment by Juliano (talk | contribs)   04:55, 22 October 2010

Don't get me wrong, but I'll have to partially revert some of the changes. I develop and run this extension on my live site, which is MediaWiki 1.16 (I don't want to run trunk MediaWiki on my live site, for clear reasons). ParserOptions::addExtraKey() was added in r70822, and is not included in 1.16.

For now, I'll make it use ->addExtraKey() when it is available, and fall back to the old class when it is not. The old class will be deprecated now, and completely removed when MediaWiki 1.17 is released.

Overall, this ->addExtraKey() is a great improvement, and it is good to deprecate this hack. Thanks!

Status & tagging log