Index: branches/werdna/restrictions-separation/includes/Parser.php |
— | — | @@ -105,6 +105,7 @@ |
106 | 106 | // multiple SQL queries for the same string |
107 | 107 | $mTemplatePath; // stores an unsorted hash of all the templates already loaded |
108 | 108 | // in this path. Used for loop detection. |
| 109 | + var $mTlTemplates; |
109 | 110 | |
110 | 111 | # Temporary |
111 | 112 | # These are variables reset at least once per parse regardless of $clearState |
— | — | @@ -234,6 +235,8 @@ |
235 | 236 | ); |
236 | 237 | $this->mDefaultSort = false; |
237 | 238 | |
| 239 | + $this->mTlTemplates = array (); |
| 240 | + |
238 | 241 | wfRunHooks( 'ParserClearState', array( &$this ) ); |
239 | 242 | wfProfileOut( __METHOD__ ); |
240 | 243 | } |
— | — | @@ -288,6 +291,18 @@ |
289 | 292 | |
290 | 293 | $this->mOptions = $options; |
291 | 294 | $this->mTitle =& $title; |
| 295 | + |
| 296 | + if ($this->mTitle->areRestrictionsCascading()) { |
| 297 | + $article = new Article($this->mTitle); |
| 298 | + $template_titles = $article->getUsedTemplates(); |
| 299 | + |
| 300 | + $this->mTlTemplates = array (); |
| 301 | + |
| 302 | + foreach ($this->mTlTemplates as $template) { |
| 303 | + $this->mTlTemplates[] = $template->getPrefixedText(); |
| 304 | + } |
| 305 | + } |
| 306 | + |
292 | 307 | $oldRevisionId = $this->mRevisionId; |
293 | 308 | $oldRevisionTimestamp = $this->mRevisionTimestamp; |
294 | 309 | if( $revid !== null ) { |
— | — | @@ -3051,22 +3066,19 @@ |
3052 | 3067 | # If this page is subject to cascading restrictions, check that the template is included in templatelinks |
3053 | 3068 | if ($this->mTitle->areRestrictionsCascading()) { |
3054 | 3069 | # Subject to cascading restrictions. Check for templatelinks entry |
3055 | | - $cc_article = new Article( $this->mTitle ); |
3056 | 3070 | |
3057 | | - $cc_dbr =& wfGetDB( DB_SLAVE ); |
3058 | | - |
3059 | | - $cc_res = $cc_dbr->selectField( 'templatelinks', 'tl_from', |
3060 | | - array( 'tl_from' => $cc_article->getID(), 'tl_namespace' => $ns, 'tl_title' => $part1 ), |
3061 | | - __METHOD__ ); |
3062 | | - |
3063 | 3071 | # Use mTlUpdatePages to avoid recursion. |
3064 | 3072 | if (!$this->mTlUpdatePages) { |
3065 | 3073 | $this->mTlUpdatePages = array (); |
3066 | 3074 | } |
3067 | 3075 | |
| 3076 | + $res = in_array($part1, $this->mTlTemplates); |
| 3077 | + |
3068 | 3078 | if (!$res && !in_array($this->mTitle->getPrefixedText(), $this->mTlUpdatePages)) { |
| 3079 | + $cc_article = new Article( $this->mTitle ); |
| 3080 | + |
3069 | 3081 | # This title needs a templatelinks refresh. Do it now. |
3070 | | - wfDebug("Needs templatelinks refresh."); |
| 3082 | + wfDebug("Needs templatelinks refresh.\n"); |
3071 | 3083 | |
3072 | 3084 | $this->mTlUpdatePages[] = $this->mTitle->getPrefixedText(); |
3073 | 3085 | |
— | — | @@ -3079,6 +3091,7 @@ |
3080 | 3092 | # Parse the text |
3081 | 3093 | $cc_options = new ParserOptions; |
3082 | 3094 | $cc_options->setTidy(true); |
| 3095 | + |
3083 | 3096 | # The below is what I'm worried about recursion in. |
3084 | 3097 | $cc_poutput = $wgParser->parse( $cc_text, $this->mTitle, $cc_options, true, true, $cc_newid ); |
3085 | 3098 | |