From 140e894bde32a28fd0647b84db2da8538697ea95 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 30 Jan 2008 02:52:14 +0000 Subject: [PATCH] Fixed the fact that defaults in template arguments {{{x|y}}} don't work when substing templates. Now defaults in triple braces will work in PST mode, except at the top (non-template) level. This is b/c breaking. --- includes/Parser.php | 11 +++++++---- includes/Preprocessor_DOM.php | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index ae6a5ae6fb..5f56c0dbdc 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -3169,7 +3169,13 @@ class Parser $argName = trim( $nameWithSpaces ); $object = false; $text = $frame->getArgument( $argName ); - if ( $text === false && ( $this->ot['html'] || $this->ot['pre'] ) && $parts->getLength() > 0 ) { + if ( $text === false && $parts->getLength() > 0 + && ( + $this->ot['html'] + || $this->ot['pre'] + || ( $this->ot['wiki'] && $frame->isTemplate() ) + ) + ) { # No match in frame, use the supplied default $object = $parts->item( 0 )->getChildren(); } @@ -3666,9 +3672,6 @@ class Parser # Because mOutputType is OT_WIKI, this will only process {{subst:xxx}} type tags $text = $this->replaceVariables( $text ); - # Strip out etc. added via replaceVariables - #$text = $this->strip( $text, $this->mStripState, false, array( 'gallery' ) ); - # Signatures $sigText = $this->getUserSig( $user ); $text = strtr( $text, array( diff --git a/includes/Preprocessor_DOM.php b/includes/Preprocessor_DOM.php index 4e29669b77..0fa48c46f7 100644 --- a/includes/Preprocessor_DOM.php +++ b/includes/Preprocessor_DOM.php @@ -1097,7 +1097,6 @@ class PPFrame_DOM implements PPFrame { return $out; } - function __toString() { return 'frame{}'; } @@ -1127,6 +1126,13 @@ class PPFrame_DOM implements PPFrame { function loopCheck( $title ) { return !isset( $this->loopCheckHash[$title->getPrefixedDBkey()] ); } + + /** + * Return true if the frame is a template frame + */ + function isTemplate() { + return false; + } } /** @@ -1207,6 +1213,13 @@ class PPTemplateFrame_DOM extends PPFrame_DOM { } return $text; } + + /** + * Return true if the frame is a template frame + */ + function isTemplate() { + return true; + } } class PPNode_DOM implements PPNode { -- 2.20.1