r75183 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75182‎ | r75183 | r75184 >
Date:05:01, 22 October 2010
Author:juliano
Status:deferred
Tags:
Comment:
Partially revert r74593 to make it work again with current stable MediaWiki
1.16.

Deprecated WikilogParserCache and added compatibility code to use the new
ParserOptions::addExtraKey() when running in current trunk MediaWiki. This
will go away in Wikilog 1.3.x (after MediaWiki 1.17 is released).
Modified paths:
  • /trunk/extensions/Wikilog/TODO (modified) (history)
  • /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,6 +82,7 @@
8383 // WikilogParser.php
8484 'WikilogParser' => $dir . 'WikilogParser.php',
8585 'WikilogParserOutput' => $dir . 'WikilogParser.php',
 86+ 'WikilogParserCache' => $dir . 'WikilogParser.php',
8687
8788 // WikilogItemPager.php
8889 'WikilogItemPager' => $dir . 'WikilogItemPager.php',
Index: trunk/extensions/Wikilog/TODO
@@ -24,3 +24,6 @@
2525 * Remove Mw1.16 compatibility boilerplate in:
2626 - WikilogComment::getCommentArticleTitle() (GAID_FOR_UPDATE).
2727 - 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 @@
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+ * @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 @@
6060 * parser that we could mess up without interfering with normal page
6161 * rendering, and we can't create a new instance because of too many
6262 * broken extensions around. Check self::parserSanityCheck().
 63+ *
 64+ * @todo (In Wikilog 1.3.x) Remove deprecated WikilogParserCache
 65+ * in favor of ParserOptions::addExtraKey().
6366 */
6467 public static function parsedArticle( Title $title, $feed = false ) {
6568 global $wgWikilogCloneParser;
@@ -73,20 +76,28 @@
7477 $useParserCache = $wgEnableParserCache &&
7578 intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
7679 $article->exists();
 80+ $parserCacheClass = "ParserCache";
7781
7882 # Parser options.
7983 $parserOpt = ParserOptions::newFromUser( $wgUser );
8084 $parserOpt->setTidy( true );
8185 if ( $feed ) {
8286 $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+ }
8495 } else {
8596 $parserOpt->enableLimitReport();
8697 }
8798
8899 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();
91102
92103 # Look for the parsed article output in the parser cache.
93104 $parserOutput = $parserCache->get( $article, $parserOpt );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74593Remove WikilogParserCache. Use $parserOpt->addExtraKey()...platonides13:57, 10 October 2010

Status & tagging log