| Index: trunk/phase3/includes/Article.php |
| — | — | @@ -746,12 +746,7 @@ |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | # Should the parser cache be used? |
| 750 | | - $pcache = $wgEnableParserCache |
| 751 | | - && intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 |
| 752 | | - && $this->exists() |
| 753 | | - && empty( $oldid ) |
| 754 | | - && !$this->mTitle->isCssOrJsPage() |
| 755 | | - && !$this->mTitle->isCssJsSubpage(); |
| | 750 | + $pcache = $this->useParserCache( $oldid ); |
| 756 | 751 | wfDebug( 'Article::view using parser cache: ' . ($pcache ? 'yes' : 'no' ) . "\n" ); |
| 757 | 752 | if ( $wgUser->getOption( 'stubthreshold' ) ) { |
| 758 | 753 | wfIncrStats( 'pcache_miss_stub' ); |
| — | — | @@ -762,7 +757,6 @@ |
| 763 | 758 | // This is an internally redirected page view. |
| 764 | 759 | // We'll need a backlink to the source page for navigation. |
| 765 | 760 | if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) { |
| 766 | | - $sk = $wgUser->getSkin(); |
| 767 | 761 | $redir = $sk->makeKnownLinkObj( $this->mRedirectedFrom, '', 'redirect=no' ); |
| 768 | 762 | $s = wfMsg( 'redirectedfrom', $redir ); |
| 769 | 763 | $wgOut->setSubtitle( $s ); |
| — | — | @@ -779,7 +773,6 @@ |
| 780 | 774 | // If it was reported from a trusted site, supply a backlink. |
| 781 | 775 | global $wgRedirectSources; |
| 782 | 776 | if( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) { |
| 783 | | - $sk = $wgUser->getSkin(); |
| 784 | 777 | $redir = $sk->makeExternalLink( $rdfrom, $rdfrom ); |
| 785 | 778 | $s = wfMsg( 'redirectedfrom', $redir ); |
| 786 | 779 | $wgOut->setSubtitle( $s ); |
| — | — | @@ -797,6 +790,7 @@ |
| 798 | 791 | $outputDone = true; |
| 799 | 792 | } |
| 800 | 793 | } |
| | 794 | + # Fetch content and check for errors |
| 801 | 795 | if ( !$outputDone ) { |
| 802 | 796 | $text = $this->getContent(); |
| 803 | 797 | if ( $text === false ) { |
| — | — | @@ -819,7 +813,6 @@ |
| 820 | 814 | } |
| 821 | 815 | |
| 822 | 816 | # We're looking at an old revision |
| 823 | | - |
| 824 | 817 | if ( !empty( $oldid ) ) { |
| 825 | 818 | $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
| 826 | 819 | if( is_null( $this->mRevision ) ) { |
| — | — | @@ -838,16 +831,13 @@ |
| 839 | 832 | } |
| 840 | 833 | } |
| 841 | 834 | } |
| 842 | | - |
| 843 | 835 | } |
| 844 | | - } |
| 845 | | - if( !$outputDone ) { |
| | 836 | + |
| 846 | 837 | $wgOut->setRevisionId( $this->getRevIdFetched() ); |
| 847 | 838 | |
| 848 | 839 | // Pages containing custom CSS or JavaScript get special treatment |
| 849 | 840 | if( $this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage() ) { |
| 850 | 841 | $wgOut->addHtml( wfMsgExt( 'clearyourcache', 'parse' ) ); |
| 851 | | - |
| 852 | 842 | // Give hooks a chance to customise the output |
| 853 | 843 | if( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->mTitle, $wgOut ) ) ) { |
| 854 | 844 | // Wrap the whole lot in a <pre> and don't parse |
| — | — | @@ -857,10 +847,7 @@ |
| 858 | 848 | $wgOut->addHtml( htmlspecialchars( $this->mContent ) ); |
| 859 | 849 | $wgOut->addHtml( "\n</pre>\n" ); |
| 860 | 850 | } |
| 861 | | - |
| 862 | | - } |
| 863 | | - |
| 864 | | - elseif ( $rt = Title::newFromRedirect( $text ) ) { |
| | 851 | + } else if ( $rt = Title::newFromRedirect( $text ) ) { |
| 865 | 852 | # Don't append the subtitle if this was an old revision |
| 866 | 853 | $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ); |
| 867 | 854 | $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); |
| — | — | @@ -889,7 +876,6 @@ |
| 890 | 877 | if( !$this->isCurrent() ) { |
| 891 | 878 | $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting ); |
| 892 | 879 | } |
| 893 | | - |
| 894 | 880 | } |
| 895 | 881 | } |
| 896 | 882 | /* title may have been set from the cache */ |
| — | — | @@ -899,8 +885,7 @@ |
| 900 | 886 | } |
| 901 | 887 | |
| 902 | 888 | # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page |
| 903 | | - if( $ns == NS_USER_TALK && |
| 904 | | - IP::isValid( $this->mTitle->getText() ) ) { |
| | 889 | + if( $ns == NS_USER_TALK && IP::isValid( $this->mTitle->getText() ) ) { |
| 905 | 890 | $wgOut->addWikiMsg('anontalkpagetext'); |
| 906 | 891 | } |
| 907 | 892 | |
| — | — | @@ -925,6 +910,20 @@ |
| 926 | 911 | wfProfileOut( __METHOD__ ); |
| 927 | 912 | } |
| 928 | 913 | |
| | 914 | + /* |
| | 915 | + * Should the parser cache be used? |
| | 916 | + */ |
| | 917 | + protected function useParserCache( $oldid ) { |
| | 918 | + global $wgUser, $wgEnableParserCache; |
| | 919 | + |
| | 920 | + return $wgEnableParserCache |
| | 921 | + && intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 |
| | 922 | + && $this->exists() |
| | 923 | + && empty( $oldid ) |
| | 924 | + && !$this->mTitle->isCssOrJsPage() |
| | 925 | + && !$this->mTitle->isCssJsSubpage(); |
| | 926 | + } |
| | 927 | + |
| 929 | 928 | protected function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) { |
| 930 | 929 | global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser; |
| 931 | 930 | |