Index: trunk/phase3/docs/memcached.txt |
— | — | @@ -159,7 +159,7 @@ |
160 | 160 | $hash: hash of user options applied to the page, see ParserOptions::optionsHash() |
161 | 161 | ex: wikidb:pcache:idhash:1-0!1!0!!en!2 |
162 | 162 | stores: ParserOutput object |
163 | | - modified by: Article::editUpdates() or Article::getOutputFromWikitext() |
| 163 | + modified by: WikiPage::doEditUpdates() or PoolWorkArticleView::doWork() |
164 | 164 | expiry: $wgParserCacheExpireTime or less if it contains short lived functions |
165 | 165 | |
166 | 166 | key: $wgDBname:pcache:idoptions:$pageid |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -708,21 +708,62 @@ |
709 | 709 | /** |
710 | 710 | * Should the parser cache be used? |
711 | 711 | * |
712 | | - * @param $user User The relevant user |
| 712 | + * @param $parserOptions ParserOptions to check |
713 | 713 | * @param $oldid int |
714 | 714 | * @return boolean |
715 | 715 | */ |
716 | | - public function isParserCacheUsed( User $user, $oldid ) { |
| 716 | + public function isParserCacheUsed( ParserOptions $parserOptions, $oldid ) { |
717 | 717 | global $wgEnableParserCache; |
718 | 718 | |
719 | 719 | return $wgEnableParserCache |
720 | | - && $user->getStubThreshold() == 0 |
| 720 | + && $parserOptions->getStubThreshold() == 0 |
721 | 721 | && $this->exists() |
722 | 722 | && ( $oldid === null || $oldid === 0 || $oldid === $this->getLatest() ) |
723 | 723 | && $this->mTitle->isWikitextPage(); |
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
| 727 | + * Get a ParserOutput for the given ParserOptions and revision ID. |
| 728 | + * The the parser cache will be used if possible. |
| 729 | + * |
| 730 | + * @since 1.19 |
| 731 | + * @param $parserOptions ParserOptions to use for the parse operation |
| 732 | + * @param $oldid Revision ID to get the text from, passing null or 0 will |
| 733 | + * get the current revision (default value) |
| 734 | + * @return ParserOutput or false if the revision was not found |
| 735 | + */ |
| 736 | + public function getParserOutput( ParserOptions $parserOptions, $oldid = null ) { |
| 737 | + global $wgParser; |
| 738 | + |
| 739 | + wfProfileIn( __METHOD__ ); |
| 740 | + |
| 741 | + $useParserCache = $this->isParserCacheUsed( $parserOptions, $oldid ); |
| 742 | + wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
| 743 | + if ( $parserOptions->getStubThreshold() ) { |
| 744 | + wfIncrStats( 'pcache_miss_stub' ); |
| 745 | + } |
| 746 | + |
| 747 | + if ( $useParserCache ) { |
| 748 | + $parserOutput = ParserCache::singleton()->get( $this, $parserOptions ); |
| 749 | + if ( $parserOutput !== false ) { |
| 750 | + wfProfileOut( __METHOD__ ); |
| 751 | + return $parserOutput; |
| 752 | + } |
| 753 | + } |
| 754 | + |
| 755 | + if ( $oldid === null || $oldid === 0 ) { |
| 756 | + $oldid = $this->getLatest(); |
| 757 | + } |
| 758 | + |
| 759 | + $pool = new PoolWorkArticleView( $this, $parserOptions, $oldid, $useParserCache ); |
| 760 | + $pool->execute(); |
| 761 | + |
| 762 | + wfProfileOut( __METHOD__ ); |
| 763 | + |
| 764 | + return $pool->getParserOutput(); |
| 765 | + } |
| 766 | + |
| 767 | + /** |
727 | 768 | * Perform the actions of a page purging |
728 | 769 | */ |
729 | 770 | public function doPurge() { |
— | — | @@ -2671,6 +2712,183 @@ |
2672 | 2713 | */ |
2673 | 2714 | public function useParserCache( $oldid ) { |
2674 | 2715 | global $wgUser; |
2675 | | - return $this->isParserCacheUsed( $wgUser, $oldid ); |
| 2716 | + return $this->isParserCacheUsed( ParserOptions::newFromUser( $wgUser ), $oldid ); |
2676 | 2717 | } |
2677 | 2718 | } |
| 2719 | + |
| 2720 | +class PoolWorkArticleView extends PoolCounterWork { |
| 2721 | + |
| 2722 | + /** |
| 2723 | + * @var Page |
| 2724 | + */ |
| 2725 | + private $page; |
| 2726 | + |
| 2727 | + /** |
| 2728 | + * @var string |
| 2729 | + */ |
| 2730 | + private $cacheKey; |
| 2731 | + |
| 2732 | + /** |
| 2733 | + * @var integer |
| 2734 | + */ |
| 2735 | + private $revid; |
| 2736 | + |
| 2737 | + /** |
| 2738 | + * @var ParserOptions |
| 2739 | + */ |
| 2740 | + private $parserOptions; |
| 2741 | + |
| 2742 | + /** |
| 2743 | + * @var string|null |
| 2744 | + */ |
| 2745 | + private $text; |
| 2746 | + |
| 2747 | + /** |
| 2748 | + * @var ParserOutput|false |
| 2749 | + */ |
| 2750 | + private $parserOutput = false; |
| 2751 | + |
| 2752 | + /** |
| 2753 | + * @var bool |
| 2754 | + */ |
| 2755 | + private $isDirty = false; |
| 2756 | + |
| 2757 | + /** |
| 2758 | + * @var Status|false |
| 2759 | + */ |
| 2760 | + private $error = false; |
| 2761 | + |
| 2762 | + /** |
| 2763 | + * Constructor |
| 2764 | + * |
| 2765 | + * @param $page Page |
| 2766 | + * @param $revid Integer: ID of the revision being parsed |
| 2767 | + * @param $useParserCache Boolean: whether to use the parser cache |
| 2768 | + * @param $parserOptions parserOptions to use for the parse operation |
| 2769 | + * @param $text String: text to parse or null to load it |
| 2770 | + */ |
| 2771 | + function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $text = null ) { |
| 2772 | + $this->page = $page; |
| 2773 | + $this->revid = $revid; |
| 2774 | + $this->cacheable = $useParserCache; |
| 2775 | + $this->parserOptions = $parserOptions; |
| 2776 | + $this->text = $text; |
| 2777 | + $this->cacheKey = ParserCache::singleton()->getKey( $page, $parserOptions ); |
| 2778 | + parent::__construct( 'ArticleView', $this->cacheKey . ':revid:' . $revid ); |
| 2779 | + } |
| 2780 | + |
| 2781 | + /** |
| 2782 | + * Get the ParserOutput from this object, or false in case of failure |
| 2783 | + * |
| 2784 | + * @return ParserOutput |
| 2785 | + */ |
| 2786 | + public function getParserOutput() { |
| 2787 | + return $this->parserOutput; |
| 2788 | + } |
| 2789 | + |
| 2790 | + /** |
| 2791 | + * Get whether the ParserOutput is a dirty one (i.e. expired) |
| 2792 | + * |
| 2793 | + * @return bool |
| 2794 | + */ |
| 2795 | + public function getIsDirty() { |
| 2796 | + return $this->isDirty(); |
| 2797 | + } |
| 2798 | + |
| 2799 | + /** |
| 2800 | + * Get a Status object in case of error or false otherwise |
| 2801 | + * |
| 2802 | + * @return Status|false |
| 2803 | + */ |
| 2804 | + public function getError() { |
| 2805 | + return $this->error; |
| 2806 | + } |
| 2807 | + |
| 2808 | + /** |
| 2809 | + * @return bool |
| 2810 | + */ |
| 2811 | + function doWork() { |
| 2812 | + global $wgParser, $wgUseFileCache; |
| 2813 | + |
| 2814 | + $isCurrent = $this->revid === $this->page->getLatest(); |
| 2815 | + |
| 2816 | + if ( $this->text !== null ) { |
| 2817 | + $text = $this->text; |
| 2818 | + } elseif ( $isCurrent ) { |
| 2819 | + $text = $this->page->getRawText(); |
| 2820 | + } else { |
| 2821 | + $rev = Revision::newFromTitle( $this->page->getTitle(), $this->revid ); |
| 2822 | + if ( $rev === null ) { |
| 2823 | + return false; |
| 2824 | + } |
| 2825 | + $text = $rev->getText(); |
| 2826 | + } |
| 2827 | + |
| 2828 | + $time = - wfTime(); |
| 2829 | + $this->parserOutput = $wgParser->parse( $text, $this->page->getTitle(), |
| 2830 | + $this->parserOptions, true, true, $this->revid ); |
| 2831 | + $time += wfTime(); |
| 2832 | + |
| 2833 | + # Timing hack |
| 2834 | + if ( $time > 3 ) { |
| 2835 | + wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time, |
| 2836 | + $this->page->getTitle()->getPrefixedDBkey() ) ); |
| 2837 | + } |
| 2838 | + |
| 2839 | + if ( $this->cacheable && $this->parserOutput->isCacheable() ) { |
| 2840 | + ParserCache::singleton()->save( $this->parserOutput, $this->page, $this->parserOptions ); |
| 2841 | + } |
| 2842 | + |
| 2843 | + // Make sure file cache is not used on uncacheable content. |
| 2844 | + // Output that has magic words in it can still use the parser cache |
| 2845 | + // (if enabled), though it will generally expire sooner. |
| 2846 | + if ( !$this->parserOutput->isCacheable() || $this->parserOutput->containsOldMagic() ) { |
| 2847 | + $wgUseFileCache = false; |
| 2848 | + } |
| 2849 | + |
| 2850 | + if ( $isCurrent ) { |
| 2851 | + $this->page->doCascadeProtectionUpdates( $this->parserOutput ); |
| 2852 | + } |
| 2853 | + } |
| 2854 | + |
| 2855 | + /** |
| 2856 | + * @return bool |
| 2857 | + */ |
| 2858 | + function getCachedWork() { |
| 2859 | + $this->parserOutput = ParserCache::singleton()->get( $this->page, $this->parserOptions ); |
| 2860 | + |
| 2861 | + if ( $this->parserOutput === false ) { |
| 2862 | + wfDebug( __METHOD__ . ": parser cache miss\n" ); |
| 2863 | + return false; |
| 2864 | + } else { |
| 2865 | + wfDebug( __METHOD__ . ": parser cache hit\n" ); |
| 2866 | + return true; |
| 2867 | + } |
| 2868 | + } |
| 2869 | + |
| 2870 | + /** |
| 2871 | + * @return bool |
| 2872 | + */ |
| 2873 | + function fallback() { |
| 2874 | + $this->parserOutput = ParserCache::singleton()->getDirty( $this->page, $this->parserOptions ); |
| 2875 | + |
| 2876 | + if ( $this->parserOutput === false ) { |
| 2877 | + wfDebugLog( 'dirty', "dirty missing\n" ); |
| 2878 | + wfDebug( __METHOD__ . ": no dirty cache\n" ); |
| 2879 | + return false; |
| 2880 | + } else { |
| 2881 | + wfDebug( __METHOD__ . ": sending dirty output\n" ); |
| 2882 | + wfDebugLog( 'dirty', "dirty output {$this->cacheKey}\n" ); |
| 2883 | + $this->isDirty = true; |
| 2884 | + return true; |
| 2885 | + } |
| 2886 | + } |
| 2887 | + |
| 2888 | + /** |
| 2889 | + * @param $status Status |
| 2890 | + */ |
| 2891 | + function error( $status ) { |
| 2892 | + $this->error = $status; |
| 2893 | + return false; |
| 2894 | + } |
| 2895 | +} |
Index: trunk/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -516,9 +516,8 @@ |
517 | 517 | } elseif ( !wfRunHooks( 'ArticleViewCustom', array( $this->mNewtext, $this->mNewPage, $out ) ) ) { |
518 | 518 | // Handled by extension |
519 | 519 | } else { |
520 | | - # Use the current version parser cache if applicable |
| 520 | + // Normal page |
521 | 521 | $wikiPage = WikiPage::factory( $this->mNewPage ); |
522 | | - $useParserCache = $wikiPage->isParserCacheUsed( $this->getUser(), $this->mNewid ); |
523 | 522 | |
524 | 523 | $parserOptions = ParserOptions::newFromContext( $this->getContext() ); |
525 | 524 | $parserOptions->enableLimitReport(); |
— | — | @@ -528,15 +527,11 @@ |
529 | 528 | $parserOptions->setEditSection( false ); |
530 | 529 | } |
531 | 530 | |
532 | | - $parserOutput = false; |
533 | | - if ( $useParserCache ) { |
534 | | - $parserOutput = ParserCache::singleton()->get( $wikiPage, $parserOptions ); |
535 | | - } |
| 531 | + $parserOutput = $wikiPage->getParserOutput( $parserOptions, $this->mNewid ); |
536 | 532 | |
| 533 | + # WikiPage::getParserOutput() should not return false, but just in case |
537 | 534 | if( $parserOutput ) { |
538 | 535 | $out->addParserOutput( $parserOutput ); |
539 | | - } else { |
540 | | - $out->addWikiTextTidy( $this->mNewtext ); |
541 | 536 | } |
542 | 537 | } |
543 | 538 | } |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -453,7 +453,7 @@ |
454 | 454 | } |
455 | 455 | |
456 | 456 | # Should the parser cache be used? |
457 | | - $useParserCache = $this->mPage->isParserCacheUsed( $wgUser, $oldid ); |
| 457 | + $useParserCache = $this->mPage->isParserCacheUsed( $parserOptions, $oldid ); |
458 | 458 | wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
459 | 459 | if ( $wgUser->getStubThreshold() ) { |
460 | 460 | wfIncrStats( 'pcache_miss_stub' ); |
— | — | @@ -550,16 +550,34 @@ |
551 | 551 | # Run the parse, protected by a pool counter |
552 | 552 | wfDebug( __METHOD__ . ": doing uncached parse\n" ); |
553 | 553 | |
554 | | - $key = $parserCache->getKey( $this, $parserOptions ); |
555 | | - $poolArticleView = new PoolWorkArticleView( $this, $key, $useParserCache, $parserOptions ); |
| 554 | + $poolArticleView = new PoolWorkArticleView( $this, $parserOptions, |
| 555 | + $this->getRevIdFetched(), $useParserCache, $this->getContent() ); |
556 | 556 | |
557 | 557 | if ( !$poolArticleView->execute() ) { |
| 558 | + $error = $poolArticleView->getError(); |
| 559 | + if ( $error ) { |
| 560 | + $wgOut->clearHTML(); // for release() errors |
| 561 | + $wgOut->enableClientCache( false ); |
| 562 | + $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
| 563 | + |
| 564 | + $errortext = $error->getWikiText( false, 'view-pool-error' ); |
| 565 | + $wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' ); |
| 566 | + } |
558 | 567 | # Connection or timeout error |
559 | 568 | wfProfileOut( __METHOD__ ); |
560 | 569 | return; |
561 | | - } else { |
562 | | - $outputDone = true; |
563 | 570 | } |
| 571 | + |
| 572 | + $this->mParserOutput = $poolArticleView->getParserOutput(); |
| 573 | + $wgOut->addParserOutput( $this->mParserOutput ); |
| 574 | + |
| 575 | + # Don't cache a dirty ParserOutput object |
| 576 | + if ( $poolArticleView->getIsDirty() ) { |
| 577 | + $wgOut->setSquidMaxage( 0 ); |
| 578 | + $wgOut->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" ); |
| 579 | + } |
| 580 | + |
| 581 | + $outputDone = true; |
564 | 582 | break; |
565 | 583 | # Should be unreachable, but just in case... |
566 | 584 | default: |
— | — | @@ -1150,67 +1168,6 @@ |
1151 | 1169 | } |
1152 | 1170 | |
1153 | 1171 | /** |
1154 | | - * Execute the uncached parse for action=view |
1155 | | - * @return bool |
1156 | | - */ |
1157 | | - public function doViewParse() { |
1158 | | - global $wgOut; |
1159 | | - |
1160 | | - $oldid = $this->getOldID(); |
1161 | | - $parserOptions = $this->getParserOptions(); |
1162 | | - |
1163 | | - # Render printable version, use printable version cache |
1164 | | - $parserOptions->setIsPrintable( $wgOut->isPrintable() ); |
1165 | | - |
1166 | | - # Don't show section-edit links on old revisions... this way lies madness. |
1167 | | - if ( !$this->isCurrent() || $wgOut->isPrintable() || !$this->getTitle()->quickUserCan( 'edit' ) ) { |
1168 | | - $parserOptions->setEditSection( false ); |
1169 | | - } |
1170 | | - |
1171 | | - $useParserCache = $this->useParserCache( $oldid ); |
1172 | | - $this->outputWikiText( $this->getContent(), $useParserCache, $parserOptions ); |
1173 | | - |
1174 | | - return true; |
1175 | | - } |
1176 | | - |
1177 | | - /** |
1178 | | - * Try to fetch an expired entry from the parser cache. If it is present, |
1179 | | - * output it and return true. If it is not present, output nothing and |
1180 | | - * return false. This is used as a callback function for |
1181 | | - * PoolCounter::executeProtected(). |
1182 | | - * |
1183 | | - * @return boolean |
1184 | | - */ |
1185 | | - public function tryDirtyCache() { |
1186 | | - global $wgOut; |
1187 | | - $parserCache = ParserCache::singleton(); |
1188 | | - $options = $this->getParserOptions(); |
1189 | | - |
1190 | | - if ( $wgOut->isPrintable() ) { |
1191 | | - $options->setIsPrintable( true ); |
1192 | | - $options->setEditSection( false ); |
1193 | | - } |
1194 | | - |
1195 | | - $output = $parserCache->getDirty( $this, $options ); |
1196 | | - |
1197 | | - if ( $output ) { |
1198 | | - wfDebug( __METHOD__ . ": sending dirty output\n" ); |
1199 | | - wfDebugLog( 'dirty', "dirty output " . $parserCache->getKey( $this, $options ) . "\n" ); |
1200 | | - $wgOut->setSquidMaxage( 0 ); |
1201 | | - $this->mParserOutput = $output; |
1202 | | - $wgOut->addParserOutput( $output ); |
1203 | | - $wgOut->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" ); |
1204 | | - |
1205 | | - return true; |
1206 | | - } else { |
1207 | | - wfDebugLog( 'dirty', "dirty missing\n" ); |
1208 | | - wfDebug( __METHOD__ . ": no dirty cache\n" ); |
1209 | | - |
1210 | | - return false; |
1211 | | - } |
1212 | | - } |
1213 | | - |
1214 | | - /** |
1215 | 1172 | * View redirect |
1216 | 1173 | * |
1217 | 1174 | * @param $target Title|Array of destination(s) to redirect |
— | — | @@ -1642,25 +1599,6 @@ |
1643 | 1600 | /**#@-*/ |
1644 | 1601 | |
1645 | 1602 | /** |
1646 | | - * Add the primary page-view wikitext to the output buffer |
1647 | | - * Saves the text into the parser cache if possible. |
1648 | | - * Updates templatelinks if it is out of date. |
1649 | | - * |
1650 | | - * @param $text String |
1651 | | - * @param $cache Boolean |
1652 | | - * @param $parserOptions mixed ParserOptions object, or boolean false |
1653 | | - */ |
1654 | | - public function outputWikiText( $text, $cache = true, $parserOptions = false ) { |
1655 | | - global $wgOut; |
1656 | | - |
1657 | | - $this->mParserOutput = $this->getOutputFromWikitext( $text, $cache, $parserOptions ); |
1658 | | - |
1659 | | - $this->doCascadeProtectionUpdates( $this->mParserOutput ); |
1660 | | - |
1661 | | - $wgOut->addParserOutput( $this->mParserOutput ); |
1662 | | - } |
1663 | | - |
1664 | | - /** |
1665 | 1603 | * Lightweight method to get the parser output for a page, checking the parser cache |
1666 | 1604 | * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to |
1667 | 1605 | * consider, so it's not appropriate to use there. |
— | — | @@ -1672,96 +1610,15 @@ |
1673 | 1611 | * @return ParserOutput or false if the given revsion ID is not found |
1674 | 1612 | */ |
1675 | 1613 | public function getParserOutput( $oldid = null, User $user = null ) { |
1676 | | - global $wgEnableParserCache, $wgUser; |
| 1614 | + global $wgUser; |
| 1615 | + |
1677 | 1616 | $user = is_null( $user ) ? $wgUser : $user; |
| 1617 | + $parserOptions = $this->mPage->makeParserOptions( $user ); |
1678 | 1618 | |
1679 | | - wfProfileIn( __METHOD__ ); |
1680 | | - // Should the parser cache be used? |
1681 | | - $useParserCache = $wgEnableParserCache && |
1682 | | - $user->getStubThreshold() == 0 && |
1683 | | - $this->mPage->exists() && |
1684 | | - $oldid === null; |
1685 | | - |
1686 | | - wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
1687 | | - |
1688 | | - if ( $user->getStubThreshold() ) { |
1689 | | - wfIncrStats( 'pcache_miss_stub' ); |
1690 | | - } |
1691 | | - |
1692 | | - if ( $useParserCache ) { |
1693 | | - $options = $this->mPage->makeParserOptions( $user ); |
1694 | | - $parserOutput = ParserCache::singleton()->get( $this, $options ); |
1695 | | - if ( $parserOutput !== false ) { |
1696 | | - wfProfileOut( __METHOD__ ); |
1697 | | - return $parserOutput; |
1698 | | - } |
1699 | | - } |
1700 | | - |
1701 | | - // Cache miss; parse and output it. |
1702 | | - if ( $oldid === null ) { |
1703 | | - $text = $this->mPage->getRawText(); |
1704 | | - } else { |
1705 | | - $rev = Revision::newFromTitle( $this->getTitle(), $oldid ); |
1706 | | - if ( $rev === null ) { |
1707 | | - wfProfileOut( __METHOD__ ); |
1708 | | - return false; |
1709 | | - } |
1710 | | - $text = $rev->getText(); |
1711 | | - } |
1712 | | - |
1713 | | - $output = $this->getOutputFromWikitext( $text, $useParserCache ); |
1714 | | - wfProfileOut( __METHOD__ ); |
1715 | | - return $output; |
| 1619 | + return $this->mPage->getParserOutput( $parserOptions, $oldid ); |
1716 | 1620 | } |
1717 | 1621 | |
1718 | 1622 | /** |
1719 | | - * This does all the heavy lifting for outputWikitext, except it returns the parser |
1720 | | - * output instead of sending it straight to $wgOut. Makes things nice and simple for, |
1721 | | - * say, embedding thread pages within a discussion system (LiquidThreads) |
1722 | | - * |
1723 | | - * @param $text string |
1724 | | - * @param $cache boolean |
1725 | | - * @param $parserOptions parsing options, defaults to false |
1726 | | - * @return ParserOutput |
1727 | | - */ |
1728 | | - public function getOutputFromWikitext( $text, $cache = true, $parserOptions = false ) { |
1729 | | - global $wgParser, $wgEnableParserCache, $wgUseFileCache; |
1730 | | - |
1731 | | - if ( !$parserOptions ) { |
1732 | | - $parserOptions = $this->getParserOptions(); |
1733 | | - } |
1734 | | - |
1735 | | - $time = - wfTime(); |
1736 | | - $this->mParserOutput = $wgParser->parse( $text, $this->getTitle(), |
1737 | | - $parserOptions, true, true, $this->getRevIdFetched() ); |
1738 | | - $time += wfTime(); |
1739 | | - |
1740 | | - # Timing hack |
1741 | | - if ( $time > 3 ) { |
1742 | | - wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time, |
1743 | | - $this->getTitle()->getPrefixedDBkey() ) ); |
1744 | | - } |
1745 | | - |
1746 | | - if ( $wgEnableParserCache && $cache && $this->mParserOutput->isCacheable() ) { |
1747 | | - $parserCache = ParserCache::singleton(); |
1748 | | - $parserCache->save( $this->mParserOutput, $this, $parserOptions ); |
1749 | | - } |
1750 | | - |
1751 | | - // Make sure file cache is not used on uncacheable content. |
1752 | | - // Output that has magic words in it can still use the parser cache |
1753 | | - // (if enabled), though it will generally expire sooner. |
1754 | | - if ( !$this->mParserOutput->isCacheable() || $this->mParserOutput->containsOldMagic() ) { |
1755 | | - $wgUseFileCache = false; |
1756 | | - } |
1757 | | - |
1758 | | - if ( $this->isCurrent() ) { |
1759 | | - $this->mPage->doCascadeProtectionUpdates( $this->mParserOutput ); |
1760 | | - } |
1761 | | - |
1762 | | - return $this->mParserOutput; |
1763 | | - } |
1764 | | - |
1765 | | - /** |
1766 | 1623 | * Get parser options suitable for rendering the primary article wikitext |
1767 | 1624 | * @return ParserOptions|false |
1768 | 1625 | */ |
— | — | @@ -2063,68 +1920,3 @@ |
2064 | 1921 | } |
2065 | 1922 | // ****** |
2066 | 1923 | } |
2067 | | - |
2068 | | -class PoolWorkArticleView extends PoolCounterWork { |
2069 | | - |
2070 | | - /** |
2071 | | - * @var Article |
2072 | | - */ |
2073 | | - private $mArticle; |
2074 | | - |
2075 | | - function __construct( $article, $key, $useParserCache, $parserOptions ) { |
2076 | | - parent::__construct( 'ArticleView', $key ); |
2077 | | - $this->mArticle = $article; |
2078 | | - $this->cacheable = $useParserCache; |
2079 | | - $this->parserOptions = $parserOptions; |
2080 | | - } |
2081 | | - |
2082 | | - /** |
2083 | | - * @return bool |
2084 | | - */ |
2085 | | - function doWork() { |
2086 | | - return $this->mArticle->doViewParse(); |
2087 | | - } |
2088 | | - |
2089 | | - /** |
2090 | | - * @return bool |
2091 | | - */ |
2092 | | - function getCachedWork() { |
2093 | | - global $wgOut; |
2094 | | - |
2095 | | - $parserCache = ParserCache::singleton(); |
2096 | | - $this->mArticle->mParserOutput = $parserCache->get( $this->mArticle, $this->parserOptions ); |
2097 | | - |
2098 | | - if ( $this->mArticle->mParserOutput !== false ) { |
2099 | | - wfDebug( __METHOD__ . ": showing contents parsed by someone else\n" ); |
2100 | | - $wgOut->addParserOutput( $this->mArticle->mParserOutput ); |
2101 | | - # Ensure that UI elements requiring revision ID have |
2102 | | - # the correct version information. |
2103 | | - $wgOut->setRevisionId( $this->mArticle->getLatest() ); |
2104 | | - return true; |
2105 | | - } |
2106 | | - return false; |
2107 | | - } |
2108 | | - |
2109 | | - /** |
2110 | | - * @return bool |
2111 | | - */ |
2112 | | - function fallback() { |
2113 | | - return $this->mArticle->tryDirtyCache(); |
2114 | | - } |
2115 | | - |
2116 | | - /** |
2117 | | - * @param $status Status |
2118 | | - */ |
2119 | | - function error( $status ) { |
2120 | | - global $wgOut; |
2121 | | - |
2122 | | - $wgOut->clearHTML(); // for release() errors |
2123 | | - $wgOut->enableClientCache( false ); |
2124 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
2125 | | - |
2126 | | - $errortext = $status->getWikiText( false, 'view-pool-error' ); |
2127 | | - $wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' ); |
2128 | | - |
2129 | | - return false; |
2130 | | - } |
2131 | | -} |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -168,6 +168,7 @@ |
169 | 169 | 'PoolCounter' => 'includes/PoolCounter.php', |
170 | 170 | 'PoolCounter_Stub' => 'includes/PoolCounter.php', |
171 | 171 | 'PoolCounterWork' => 'includes/PoolCounter.php', |
| 172 | + 'PoolWorkArticleView' => 'includes/WikiPage.php', |
172 | 173 | 'Preferences' => 'includes/Preferences.php', |
173 | 174 | 'PreferencesForm' => 'includes/Preferences.php', |
174 | 175 | 'PrefixSearch' => 'includes/PrefixSearch.php', |