Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -91,9 +91,9 @@ |
92 | 92 | */ |
93 | 93 | # Persistent: |
94 | 94 | var $mTagHooks, $mTransparentTagHooks, $mFunctionHooks, $mFunctionSynonyms, $mVariables, |
95 | | - $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerIndex, $mPreprocessor, |
96 | | - $mExtLinkBracketedRegex, $mUrlProtocols, $mDefaultStripList, $mVarCache, $mConf, |
97 | | - $mFunctionTagHooks; |
| 95 | + $mSubsts, $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerIndex, |
| 96 | + $mPreprocessor, $mExtLinkBracketedRegex, $mUrlProtocols, $mDefaultStripList, |
| 97 | + $mVarCache, $mConf, $mFunctionTagHooks; |
98 | 98 | |
99 | 99 | |
100 | 100 | # Cleared with clearState(): |
— | — | @@ -2617,15 +2617,17 @@ |
2618 | 2618 | } |
2619 | 2619 | |
2620 | 2620 | /** |
2621 | | - * initialise the magic variables (like CURRENTMONTHNAME) |
| 2621 | + * initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers |
2622 | 2622 | * |
2623 | 2623 | * @private |
2624 | 2624 | */ |
2625 | 2625 | function initialiseVariables() { |
2626 | 2626 | wfProfileIn( __METHOD__ ); |
2627 | 2627 | $variableIDs = MagicWord::getVariableIDs(); |
| 2628 | + $substIDs = MagicWord::getSubstIDs(); |
2628 | 2629 | |
2629 | 2630 | $this->mVariables = new MagicWordArray( $variableIDs ); |
| 2631 | + $this->mSubsts = new MagicWordArray( $substIDs ); |
2630 | 2632 | wfProfileOut( __METHOD__ ); |
2631 | 2633 | } |
2632 | 2634 | |
— | — | @@ -2796,12 +2798,19 @@ |
2797 | 2799 | # SUBST |
2798 | 2800 | wfProfileIn( __METHOD__.'-modifiers' ); |
2799 | 2801 | if ( !$found ) { |
2800 | | - $mwSubst = MagicWord::get( 'subst' ); |
2801 | | - if ( $mwSubst->matchStartAndRemove( $part1 ) xor $this->ot['wiki'] ) { |
2802 | | - # One of two possibilities is true: |
2803 | | - # 1) Found SUBST but not in the PST phase |
2804 | | - # 2) Didn't find SUBST and in the PST phase |
2805 | | - # In either case, return without further processing |
| 2802 | + |
| 2803 | + $substMatch = $this->mSubsts->matchVariableStartToEnd( $part1 ); |
| 2804 | + |
| 2805 | + # Possibilities for substMatch[0]: "subst", "safesubst" or FALSE |
| 2806 | + # Whether to include depends also on whether we are in the pre-save-transform |
| 2807 | + # |
| 2808 | + # safesubst || (subst && PST) => transclude (handled by if) |
| 2809 | + # (false && PST) || (subst && !PST) => return input (handled by else if) |
| 2810 | + # false && !PST => transclude (no handling needed here) |
| 2811 | + if ( $substMatch[0] && ( $this->ot['wiki'] || $substMatch[0] == 'safesubst' ) ) { |
| 2812 | + $part1 = $substMatch[1]; |
| 2813 | + |
| 2814 | + } else if ( $substMatch[0] xor $this->ot['wiki'] ) { |
2806 | 2815 | $text = $frame->virtualBracketedImplode( '{{', '|', '}}', $titleWithSpaces, $args ); |
2807 | 2816 | $isLocalObj = true; |
2808 | 2817 | $found = true; |
Index: trunk/phase3/includes/MagicWord.php |
— | — | @@ -165,6 +165,10 @@ |
166 | 166 | 'nocontentconvert', |
167 | 167 | ); |
168 | 168 | |
| 169 | + static public $mSubstIDs = array( |
| 170 | + 'subst', |
| 171 | + 'safesubst', |
| 172 | + ); |
169 | 173 | |
170 | 174 | static public $mObjects = array(); |
171 | 175 | static public $mDoubleUnderscoreArray = null; |
— | — | @@ -216,6 +220,13 @@ |
217 | 221 | return self::$mVariableIDs; |
218 | 222 | } |
219 | 223 | |
| 224 | + /** |
| 225 | + * Get an array of parser substitution modifier IDs |
| 226 | + */ |
| 227 | + static function getSubstIDs() { |
| 228 | + return self::$mSubstIDs; |
| 229 | + } |
| 230 | + |
220 | 231 | /* Allow external reads of TTL array */ |
221 | 232 | static function getCacheTTL($id) { |
222 | 233 | if (array_key_exists($id,self::$mCacheTTLs)) { |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -264,7 +264,8 @@ |
265 | 265 | 'subjectpagename' => array( 1, 'SUBJECTPAGENAME', 'ARTICLEPAGENAME' ), |
266 | 266 | 'subjectpagenamee' => array( 1, 'SUBJECTPAGENAMEE', 'ARTICLEPAGENAMEE' ), |
267 | 267 | 'msg' => array( 0, 'MSG:' ), |
268 | | - 'subst' => array( 0, 'SUBST:' ), |
| 268 | + 'subst' => array( 0, 'SUBST:$1' ), |
| 269 | + 'safesubst' => array( 0, 'SAFESUBST:$1' ), |
269 | 270 | 'msgnw' => array( 0, 'MSGNW:' ), |
270 | 271 | 'img_thumbnail' => array( 1, 'thumbnail', 'thumb' ), |
271 | 272 | 'img_manualthumb' => array( 1, 'thumbnail=$1', 'thumb=$1'), |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -809,6 +809,7 @@ |
810 | 810 | * (bug 22248) Output extension URLs in meta=siteinfo&siprop=extensions |
811 | 811 | * Support key-params arrays in 'descriptionmsg' in meta=siteinfo&siprop=extensions |
812 | 812 | * (bug 21922) YAML output should quote asterisk when used as key |
| 813 | +* (bug 22297) safesubst: to allow substitution without breaking transclusion |
813 | 814 | |
814 | 815 | === Languages updated in 1.16 === |
815 | 816 | |