Index: branches/werdna/restrictions-separation/includes/Article.php |
— | — | @@ -792,7 +792,7 @@ |
793 | 793 | $wgOut->addParserOutputNoText( $parseout ); |
794 | 794 | } else if ( $pcache ) { |
795 | 795 | # Display content and save to parser cache |
796 | | - $wgOut->addPrimaryWikiText( $text, $this ); |
| 796 | + $this->outputWikitext( $text ); |
797 | 797 | } else { |
798 | 798 | # Display content, don't attempt to save to parser cache |
799 | 799 | # Don't show section-edit links on old revisions... this way lies madness. |
— | — | @@ -800,7 +800,7 @@ |
801 | 801 | $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false ); |
802 | 802 | } |
803 | 803 | # Display content and don't save to parser cache |
804 | | - $wgOut->addPrimaryWikiText( $text, $this, false ); |
| 804 | + $this->outputWikitext( $text, false ); |
805 | 805 | |
806 | 806 | if( !$this->isCurrent() ) { |
807 | 807 | $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting ); |
— | — | @@ -2794,6 +2794,64 @@ |
2795 | 2795 | |
2796 | 2796 | return $summary; |
2797 | 2797 | } |
| 2798 | + |
| 2799 | + /** |
| 2800 | + * Add the primary page-view wikitext to the output buffer |
| 2801 | + * Saves the text into the parser cache if possible. |
| 2802 | + * |
| 2803 | + * @param string $text |
| 2804 | + * @param Article $article |
| 2805 | + * @param bool $cache |
| 2806 | + */ |
| 2807 | + public function outputWikiText( $text, $cache = true ) { |
| 2808 | + global $wgParser, $wgUser, $wgOut; |
| 2809 | + |
| 2810 | + $article = $this; |
| 2811 | + |
| 2812 | + $popts = $wgOut->parserOptions(); |
| 2813 | + $popts->setTidy(true); |
| 2814 | + $parserOutput = $wgParser->parse( $text, $article->mTitle, |
| 2815 | + $popts, true, true, $this->mRevisionId ); |
| 2816 | + $popts->setTidy(false); |
| 2817 | + if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) { |
| 2818 | + $parserCache =& ParserCache::singleton(); |
| 2819 | + $parserCache->save( $parserOutput, $article, $wgUser ); |
| 2820 | + } |
| 2821 | + |
| 2822 | + # Get templates from templatelinks |
| 2823 | + $tlTemplates_titles = $this->getUsedTemplates(); |
| 2824 | + |
| 2825 | + $tlTemplates = array (); |
| 2826 | + foreach( $tlTemplates_titles as $template_title) { |
| 2827 | + $tlTemplates[] = $template_title->getDBkey(); |
| 2828 | + } |
| 2829 | + |
| 2830 | + # Get templates from parser output. |
| 2831 | + $poTemplates_allns = $parserOutput->getTemplates(); |
| 2832 | + |
| 2833 | + $poTemplates = array (); |
| 2834 | + foreach ( $poTemplates_allns as $ns_templates ) { |
| 2835 | + $poTemplates = array_merge( $poTemplates, $ns_templates ); |
| 2836 | + } |
| 2837 | + |
| 2838 | + # Get the diff |
| 2839 | + $templates_diff = array_diff( $poTemplates, $tlTemplates ); |
| 2840 | + |
| 2841 | + if (count( $templates_diff ) > 0) { |
| 2842 | + # Whee, link updates time. |
| 2843 | + $u = new LinksUpdate( $this->mTitle, $parserOutput ); |
| 2844 | + |
| 2845 | + $dbw =& wfGetDb( DB_MASTER ); |
| 2846 | + $dbw->begin(); |
| 2847 | + |
| 2848 | + $u->doUpdate(); |
| 2849 | + |
| 2850 | + $dbw->commit(); |
| 2851 | + } |
| 2852 | + |
| 2853 | + $wgOut->addParserOutput( $parserOutput ); |
| 2854 | + } |
| 2855 | + |
2798 | 2856 | } |
2799 | 2857 | |
2800 | 2858 | ?> |
Index: branches/werdna/restrictions-separation/includes/Parser.php |
— | — | @@ -95,7 +95,6 @@ |
96 | 96 | */ |
97 | 97 | # Persistent: |
98 | 98 | var $mTagHooks, $mFunctionHooks, $mFunctionSynonyms, $mVariables; |
99 | | - var $mTlDoneUpdateFor; |
100 | 99 | |
101 | 100 | # Cleared with clearState(): |
102 | 101 | var $mOutput, $mAutonumber, $mDTopen, $mStripState; |
— | — | @@ -106,7 +105,6 @@ |
107 | 106 | // multiple SQL queries for the same string |
108 | 107 | $mTemplatePath; // stores an unsorted hash of all the templates already loaded |
109 | 108 | // in this path. Used for loop detection. |
110 | | - var $mTlTemplates; |
111 | 109 | |
112 | 110 | # Temporary |
113 | 111 | # These are variables reset at least once per parse regardless of $clearState |
— | — | @@ -236,8 +234,6 @@ |
237 | 235 | ); |
238 | 236 | $this->mDefaultSort = false; |
239 | 237 | |
240 | | - $this->mTlTemplates = array (); |
241 | | - |
242 | 238 | wfRunHooks( 'ParserClearState', array( &$this ) ); |
243 | 239 | wfProfileOut( __METHOD__ ); |
244 | 240 | } |
— | — | @@ -292,18 +288,6 @@ |
293 | 289 | |
294 | 290 | $this->mOptions = $options; |
295 | 291 | $this->mTitle =& $title; |
296 | | - |
297 | | - if ($this->mTitle->areRestrictionsCascading()) { |
298 | | - $article = new Article($this->mTitle); |
299 | | - $template_titles = $article->getUsedTemplates(); |
300 | | - |
301 | | - $this->mTlTemplates = array (); |
302 | | - |
303 | | - foreach ($this->mTlTemplates as $template) { |
304 | | - $this->mTlTemplates[] = $template->getPrefixedText(); |
305 | | - } |
306 | | - } |
307 | | - |
308 | 292 | $oldRevisionId = $this->mRevisionId; |
309 | 293 | $oldRevisionTimestamp = $this->mRevisionTimestamp; |
310 | 294 | if( $revid !== null ) { |
— | — | @@ -3064,45 +3048,7 @@ |
3065 | 3049 | } |
3066 | 3050 | $title = Title::newFromText( $part1, $ns ); |
3067 | 3051 | |
3068 | | - # If this page is subject to cascading restrictions, check that the template is included in templatelinks |
3069 | | - if ( $this->mTitle->areRestrictionsCascading( ) ) { |
3070 | | - # Subject to cascading restrictions. Check for templatelinks entry |
3071 | 3052 | |
3072 | | - $res = in_array( $part1, $this->mTlTemplates ); |
3073 | | - |
3074 | | - if ( !is_array( $this->mTlDoneUpdateFor ) ) { |
3075 | | - $this->mTlDoneUpdateFor = array (); |
3076 | | - } |
3077 | | - |
3078 | | - if ( !$res && !in_array( $this->mTitle->getPrefixedText(), $this->mTlDoneUpdateFor ) ) { |
3079 | | - $this->mTlDoneUpdateFor[] = $this->mTitle->getPrefixedText(); |
3080 | | - |
3081 | | - $cc_article = new Article( $this->mTitle ); |
3082 | | - |
3083 | | - # This title needs a templatelinks refresh. Do it now. |
3084 | | - wfDebug("Needs templatelinks refresh.\n"); |
3085 | | - |
3086 | | - $this->mTlUpdatePages[] = $this->mTitle->getPrefixedText(); |
3087 | | - |
3088 | | - global $wgParser; |
3089 | | - |
3090 | | - # Get content. |
3091 | | - $cc_text = $cc_article->getContent(); |
3092 | | - $cc_newid = $cc_article->getRevIdFetched(); |
3093 | | - |
3094 | | - # Parse the text |
3095 | | - $cc_options = new ParserOptions; |
3096 | | - $cc_options->setTidy(true); |
3097 | | - |
3098 | | - # The below is what I'm worried about recursion in. |
3099 | | - $cc_poutput = $wgParser->parse( $cc_text, $this->mTitle, $cc_options, true, true, $cc_newid ); |
3100 | | - |
3101 | | - # Update the links tables |
3102 | | - $u = new LinksUpdate( $this->mTitle, $cc_poutput ); |
3103 | | - $u->doUpdate(); |
3104 | | - } |
3105 | | - } |
3106 | | - |
3107 | 3053 | if ( !is_null( $title ) ) { |
3108 | 3054 | $titleText = $title->getPrefixedText(); |
3109 | 3055 | # Check for language variants if the template is not found |
Index: branches/werdna/restrictions-separation/includes/OutputPage.php |
— | — | @@ -315,14 +315,26 @@ |
316 | 316 | $this->addWikiTextTitle($text, $title, $linestart); |
317 | 317 | } |
318 | 318 | |
319 | | - private function addWikiTextTitle($text, &$title, $linestart) { |
| 319 | + function addWikiTextTitleTidy($text, &$title, $linestart = true) { |
| 320 | + addWikiTextTitle( $text, $title, $linestart, true ); |
| 321 | + } |
| 322 | + |
| 323 | + private function addWikiTextTitle($text, &$title, $linestart, $tidy = false) { |
320 | 324 | global $wgParser; |
| 325 | + |
321 | 326 | $fname = 'OutputPage:addWikiTextTitle'; |
322 | 327 | wfProfileIn($fname); |
| 328 | + |
323 | 329 | wfIncrStats('pcache_not_possible'); |
324 | | - $parserOutput = $wgParser->parse( $text, $title, $this->parserOptions(), |
| 330 | + |
| 331 | + $popts = $this->parserOptions(); |
| 332 | + $popts->setTidy($tidy); |
| 333 | + |
| 334 | + $parserOutput = $wgParser->parse( $text, $title, $popts, |
325 | 335 | $linestart, true, $this->mRevisionId ); |
| 336 | + |
326 | 337 | $this->addParserOutput( $parserOutput ); |
| 338 | + |
327 | 339 | wfProfileOut($fname); |
328 | 340 | } |
329 | 341 | |
— | — | @@ -366,6 +378,7 @@ |
367 | 379 | * @param string $text |
368 | 380 | * @param Article $article |
369 | 381 | * @param bool $cache |
| 382 | + * @deprecated Use Article::outputWikitext |
370 | 383 | */ |
371 | 384 | public function addPrimaryWikiText( $text, $article, $cache = true ) { |
372 | 385 | global $wgParser, $wgUser; |
Index: branches/werdna/restrictions-separation/includes/SpecialUndelete.php |
— | — | @@ -532,8 +532,7 @@ |
533 | 533 | |
534 | 534 | if( $this->mPreview ) { |
535 | 535 | $wgOut->addHtml( "<hr />\n" ); |
536 | | - $article = new Article ( $archive->title ); # OutputPage wants an Article obj |
537 | | - $wgOut->addPrimaryWikiText( $rev->getText(), $article, false ); |
| 536 | + $wgOut->addWikiTextTitle( $rev->getText(), $archive->title, false ); |
538 | 537 | } |
539 | 538 | |
540 | 539 | $self = SpecialPage::getTitleFor( "Undelete" ); |
Index: branches/werdna/restrictions-separation/includes/Title.php |
— | — | @@ -1364,7 +1364,7 @@ |
1365 | 1365 | $tables = array ('templatelinks', 'page_restrictions'); |
1366 | 1366 | $where_clauses = array( 'tl_namespace' => $this->getNamespace(), 'tl_title' => $this->getDBkey(), 'tl_from=pr_page', 'pr_cascade' => 1 ); |
1367 | 1367 | |
1368 | | - $res = $dbr->select( $tables, $cols, $where_clauses, __METHOD); |
| 1368 | + $res = $dbr->select( $tables, $cols, $where_clauses, __METHOD__); |
1369 | 1369 | |
1370 | 1370 | if ($dbr->numRows($res)) { |
1371 | 1371 | wfProfileOut(__METHOD__); |