Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F6453
PATCH.substorblank
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 10:57 PM
2014-11-21 22:57:46 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
PATCH.substorblank
View Options
Index: includes/parser/Parser.php
===================================================================
--- includes/parser/Parser.php (revision 61687)
+++ includes/parser/Parser.php (working copy)
@@ -2314,6 +2314,16 @@
}
/**
+ * Return value of the magic variable substing.
+ *
+ * @private
+ */
+ function getSubstOrBlank() {
+ $magicWord = MagicWord::get( 'subst' );
+ return $this->ot['wiki'] ? $magicWord->getSynonym( 0 ) : '';
+ }
+
+ /**
* Return value of a magic variable (like PAGENAME)
*
* @private
@@ -2602,6 +2612,8 @@
case 'contentlanguage':
global $wgContLanguageCode;
return $wgContLanguageCode;
+ case 'substorblank':
+ return $this->getSubstOrBlank();
default:
$ret = null;
if ( wfRunHooks( 'ParserGetVariableValueSwitch', array( &$this, &$this->mVarCache, &$index, &$ret, &$frame ) ) )
@@ -2797,15 +2809,23 @@
wfProfileIn( __METHOD__.'-modifiers' );
if ( !$found ) {
$mwSubst = MagicWord::get( 'subst' );
+
if ( $mwSubst->matchStartAndRemove( $part1 ) xor $this->ot['wiki'] ) {
# One of two possibilities is true:
# 1) Found SUBST but not in the PST phase
# 2) Didn't find SUBST and in the PST phase
- # In either case, return without further processing
- $text = $frame->virtualBracketedImplode( '{{', '|', '}}', $titleWithSpaces, $args );
+ # Either we have {{subst}} or {{subst:subst}} in which case return "subst:" or ""
+ # Or we have a broken template inclusion, in which case return the wikitext
+ $mwSubsting = MagicWord::get( 'substorblank' );
+ if ( $mwSubsting->matchVariableStartToEnd( $part1 ) ) {
+ $text = $this->getSubstOrBlank();
+ } else {
+ $text = $frame->virtualBracketedImplode( '{{', '|', '}}', $titleWithSpaces, $args );
+ }
+
$isLocalObj = true;
$found = true;
- }
+ }
}
# Variables
Index: includes/MagicWord.php
===================================================================
--- includes/MagicWord.php (revision 61687)
+++ includes/MagicWord.php (working copy)
@@ -104,6 +104,7 @@
'contentlanguage',
'numberofadmins',
'numberofviews',
+ 'substorblank',
);
/* Array of caching hints for ParserCache */
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php (revision 61687)
+++ languages/messages/MessagesEn.php (working copy)
@@ -266,6 +266,7 @@
'msg' => array( 0, 'MSG:' ),
'subst' => array( 0, 'SUBST:' ),
'msgnw' => array( 0, 'MSGNW:' ),
+ 'substorblank' => array( 0, 'SUBST' ),
'img_thumbnail' => array( 1, 'thumbnail', 'thumb' ),
'img_manualthumb' => array( 1, 'thumbnail=$1', 'thumb=$1'),
'img_right' => array( 1, 'right' ),
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5993
Default Alt Text
PATCH.substorblank (2 KB)
Attached To
Mode
T24297: There should be syntax for substitution that doesn't break normal transclusion
Attached
Detach File
Event Timeline
Log In to Comment