From 1da57d4e12457c80f3171f773d58ed9f63617030 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 11 Feb 2005 09:02:15 +0000 Subject: [PATCH] * Corrections to template loop detection --- includes/Parser.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 0e3549cb38..50777f4d56 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1991,20 +1991,25 @@ class Parser # Did we encounter this template already? If yes, it is in the cache # and we need to check for loops. if ( !$found && isset( $this->mTemplates[$part1] ) ) { - # set $text to cached message. - $text = $linestart . $this->mTemplates[$part1]; $found = true; # Infinite loop test if ( isset( $this->mTemplatePath[$part1] ) ) { $noparse = true; $found = true; - $text .= ''; + $text = $linestart . + "\{\{$part1}}" . + ''; + wfDebug( "$fname: template loop broken at '$part1'\n" ); + } else { + # set $text to cached message. + $text = $linestart . $this->mTemplates[$part1]; } } # Load from database $itcamefromthedatabase = false; + $lastPathLevel = $this->mTemplatePath; if ( !$found ) { $ns = NS_TEMPLATE; $part1 = $this->maybeDoSubpageLink( $part1, $subpage='' ); @@ -2081,9 +2086,9 @@ class Parser $text = "\n" . $text; } } - - # Empties the template path - $this->mTemplatePath = array(); + # Prune lower levels off the recursion check path + $this->mTemplatePath = $lastPathLevel; + if ( !$found ) { wfProfileOut( $fname ); return $matches[0]; @@ -2115,9 +2120,8 @@ class Parser } } } - - # Empties the template path - $this->mTemplatePath = array(); + # Prune lower levels off the recursion check path + $this->mTemplatePath = $lastPathLevel; if ( !$found ) { wfProfileOut( $fname ); -- 2.20.1