+
+ function tryParserCache( $parserOptions ) {
+ $parserCache = ParserCache::singleton();
+ $parserOutput = $parserCache->get( $article, $parserOptions );
+ if ( $parserOutput !== false ) {
+ return $parserOutput;
+ } else {
+ return false;
+ }
+ }
+
+ function getParserOutput( $oldid = null ) {
+ global $wgEnableParserCache, $wgUser, $wgOut;
+
+ // Should the parser cache be used?
+ $pcache = $wgEnableParserCache &&
+ intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
+ $this->exists() &&
+ $oldid === null;
+
+ wfDebug( __METHOD__.': using parser cache: ' . ( $pcache ? 'yes' : 'no' ) . "\n" );
+ if ( $wgUser->getOption( 'stubthreshold' ) ) {
+ wfIncrStats( 'pcache_miss_stub' );
+ }
+
+ $parserOutput = false;
+ if ( $pcache ) {
+ $parserOutput = $this->tryParserCache( $wgOut->parserOptions() );
+ }
+
+ if ( $parserOutput === false ) {
+ // Cache miss; parse and output it.
+ $rev = Revision::newFromTitle( $post->getTitle(), $oldid );
+
+ if ( $rev && $oldid ) {
+ // don't save oldids in the parser cache.
+ }
+ else if ( $rev ) {
+ $post->outputWikiText( $rev->getText(), true );
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return true;
+ }
+ }