r52326 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52325‎ | r52326 | r52327 >
Date:21:52, 23 June 2009
Author:werdna
Status:deferred (Comments)
Tags:
Comment:
Core changes for r52307
Modified paths:
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php
@@ -161,7 +161,7 @@
162162 'af_timestamp',
163163 'af_user_text',
164164 'af_user',
165 - 'af_actions'
 165+ 'af_actions',
166166 ),
167167 'conds' => $this->mConds,
168168 );
Index: trunk/phase3/includes/OutputPage.php
@@ -714,13 +714,15 @@
715715 /**
716716 * @param Article $article
717717 * @param User $user
 718+ *
 719+ * Now a wrapper around Article::tryParserCache()
718720 *
719721 * @return bool True if successful, else false.
720722 */
721723 public function tryParserCache( &$article ) {
722 - $parserCache = ParserCache::singleton();
723 - $parserOutput = $parserCache->get( $article, $this->parserOptions() );
724 - if ( $parserOutput !== false ) {
 724+ $parserOutput = $article->tryParserCache( $this->parserOptions() );
 725+
 726+ if ($parserOutput !== false) {
725727 $this->addParserOutput( $parserOutput );
726728 return true;
727729 } else {
Index: trunk/phase3/includes/Article.php
@@ -3675,6 +3675,19 @@
36763676 * @param $cache Boolean
36773677 */
36783678 public function outputWikiText( $text, $cache = true ) {
 3679+ global $wgOut;
 3680+
 3681+ $parserOutput = $this->outputFromWikitext( $text, $cache );
 3682+
 3683+ $wgOut->addParserOutput( $parserOutput );
 3684+ }
 3685+
 3686+ /**
 3687+ * This does all the heavy lifting for outputWikitext, except it returns the parser
 3688+ * output instead of sending it straight to $wgOut. Makes things nice and simple for,
 3689+ * say, embedding thread pages within a discussion system (LiquidThreads)
 3690+ */
 3691+ public function outputFromWikitext( $text, $cache = true ) {
36793692 global $wgParser, $wgOut, $wgEnableParserCache, $wgUseFileCache;
36803693
36813694 $popts = $wgOut->parserOptions();
@@ -3737,8 +3750,8 @@
37383751 $u->doUpdate();
37393752 }
37403753 }
3741 -
3742 - $wgOut->addParserOutput( $parserOutput );
 3754+
 3755+ return $parserOutput;
37433756 }
37443757
37453758 /**
@@ -3797,4 +3810,46 @@
37983811 );
37993812 }
38003813 }
 3814+
 3815+ function tryParserCache( $parserOptions ) {
 3816+ $parserCache = ParserCache::singleton();
 3817+ $parserOutput = $parserCache->get( $this, $parserOptions );
 3818+ if ( $parserOutput !== false ) {
 3819+ return $parserOutput;
 3820+ } else {
 3821+ return false;
 3822+ }
 3823+ }
 3824+
 3825+ /** Lightweight method to get the parser output for a page, checking the parser cache
 3826+ * and so on. Doesn't consider most of the stuff that Article::view is forced to
 3827+ * consider, so it's not appropriate to use there. */
 3828+ function getParserOutput( $oldid = null ) {
 3829+ global $wgEnableParserCache, $wgUser, $wgOut;
 3830+
 3831+ // Should the parser cache be used?
 3832+ $pcache = $wgEnableParserCache &&
 3833+ intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
 3834+ $this->exists() &&
 3835+ $oldid === null;
 3836+
 3837+ wfDebug( __METHOD__.': using parser cache: ' . ( $pcache ? 'yes' : 'no' ) . "\n" );
 3838+ if ( $wgUser->getOption( 'stubthreshold' ) ) {
 3839+ wfIncrStats( 'pcache_miss_stub' );
 3840+ }
 3841+
 3842+ $parserOutput = false;
 3843+ if ( $pcache ) {
 3844+ $parserOutput = $this->tryParserCache( $wgOut->parserOptions() );
 3845+ }
 3846+
 3847+ if ( $parserOutput === false ) {
 3848+ // Cache miss; parse and output it.
 3849+ $rev = Revision::newFromTitle( $this->getTitle(), $oldid );
 3850+
 3851+ return $this->outputFromWikitext( $rev->getText(), $pcache );
 3852+ } else {
 3853+ return $parserOutput;
 3854+ }
 3855+ }
38013856 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r52307Massive LiquidThreads refactoring and reorganisation:...werdna13:34, 23 June 2009

Comments

#Comment by Werdna (talk | contribs)   21:53, 23 June 2009

Includes minor unrelated stylistic change.

#Comment by Tim Starling (talk | contribs)   04:48, 6 July 2009

I think you mean getOutputFromWikitext(), not outputFromWikitext(). We use verb phrases to name functions, and this function doesn't output anything.

Status & tagging log