r70712 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70711‎ | r70712 | r70713 >
Date:16:18, 8 August 2010
Author:soxred93
Status:ok
Tags:
Comment:
(bug 22116) Add limit parameter to {{#explode:}}. Patch by Christopher Baker
Modified paths:
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -729,7 +729,7 @@
730730
731731
732732 /**
733 - * {{#explode:string | delimiter | position}}
 733+ * {{#explode:string | delimiter | position | limit}}
734734 *
735735 * Breaks "string" into chunks separated by "delimiter" and returns the
736736 * chunk identified by "position".
@@ -738,7 +738,7 @@
739739 * Note: If the divider is an empty string, single space is used instead.
740740 * Note: Empty string is returned if there are not enough exploded chunks.
741741 */
742 - function runExplode ( $parser, $inStr = '', $inDiv = '', $inPos = 0 ) {
 742+ function runExplode ( $parser, $inStr = '', $inDiv = '', $inPos = 0, $inLim = null ) {
743743 wfProfileIn( __METHOD__ );
744744
745745 $inStr = $this->killMarkers( $parser, (string)$inStr );
@@ -754,7 +754,7 @@
755755
756756 $inDiv = preg_quote( $inDiv, '/' );
757757
758 - $matches = preg_split( '/'.$inDiv.'/u', $inStr );
 758+ $matches = preg_split( '/'.$inDiv.'/u', $inStr, $inLim );
759759
760760 if( $inPos >= 0 && isset( $matches[$inPos] ) ) {
761761 $result = $matches[$inPos];

Status & tagging log