Index: trunk/phase3/includes/Parser.php |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | * settings: |
80 | 80 | * $wgUseTex*, $wgUseDynamicDates*, $wgInterwikiMagic*, |
81 | 81 | * $wgNamespacesWithSubpages, $wgAllowExternalImages*, |
82 | | - * $wgLocaltimezone, $wgAllowSpecialInclusion*, |
| 82 | + * $wgLocaltimezone, $wgAllowSpecialInclusion*, |
83 | 83 | * $wgMaxArticleSize* |
84 | 84 | * |
85 | 85 | * * only within ParserOptions |
— | — | @@ -169,12 +169,12 @@ |
170 | 170 | if ( $wgAllowSlowParserFunctions ) { |
171 | 171 | $this->setFunctionHook( 'pagesinnamespace', array( 'CoreParserFunctions', 'pagesinnamespace' ), SFH_NO_HASH ); |
172 | 172 | } |
173 | | - |
| 173 | + |
174 | 174 | $this->initialiseVariables(); |
175 | 175 | |
176 | 176 | $this->mFirstCall = false; |
177 | 177 | wfProfileOut( __METHOD__ ); |
178 | | - } |
| 178 | + } |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Clear Parser state |
— | — | @@ -206,7 +206,7 @@ |
207 | 207 | 'titles' => array() |
208 | 208 | ); |
209 | 209 | $this->mRevisionId = null; |
210 | | - |
| 210 | + |
211 | 211 | /** |
212 | 212 | * Prefix for temporary replacement strings for the multipass parser. |
213 | 213 | * \x07 should never appear in input as it's disallowed in XML. |
— | — | @@ -503,7 +503,7 @@ |
504 | 504 | $text = $q[2]; |
505 | 505 | } |
506 | 506 | } |
507 | | - |
| 507 | + |
508 | 508 | $matches[$marker] = array( $element, |
509 | 509 | $content, |
510 | 510 | Sanitizer::decodeTagAttributes( $attributes ), |
— | — | @@ -522,7 +522,7 @@ |
523 | 523 | * will be stripped in addition to other tags. This is important |
524 | 524 | * for section editing, where these comments cause confusion when |
525 | 525 | * counting the sections in the wikisource |
526 | | - * |
| 526 | + * |
527 | 527 | * @param array dontstrip contains tags which should not be stripped; |
528 | 528 | * used to prevent stipping of <gallery> when saving (fixes bug 2700) |
529 | 529 | * |
— | — | @@ -534,7 +534,7 @@ |
535 | 535 | |
536 | 536 | $uniq_prefix = $this->mUniqPrefix; |
537 | 537 | $commentState = array(); |
538 | | - |
| 538 | + |
539 | 539 | $elements = array_merge( |
540 | 540 | array( 'nowiki', 'gallery' ), |
541 | 541 | array_keys( $this->mTagHooks ) ); |
— | — | @@ -545,13 +545,13 @@ |
546 | 546 | if( $this->mOptions->getUseTeX() ) { |
547 | 547 | $elements[] = 'math'; |
548 | 548 | } |
549 | | - |
| 549 | + |
550 | 550 | # Removing $dontstrip tags from $elements list (currently only 'gallery', fixing bug 2700) |
551 | 551 | foreach ( $elements AS $k => $v ) { |
552 | 552 | if ( !in_array ( $v , $dontstrip ) ) continue; |
553 | 553 | unset ( $elements[$k] ); |
554 | 554 | } |
555 | | - |
| 555 | + |
556 | 556 | $matches = array(); |
557 | 557 | $text = Parser::extractTagsAndParams( $elements, $text, $matches, $uniq_prefix ); |
558 | 558 | |
— | — | @@ -600,7 +600,7 @@ |
601 | 601 | $output = $tag; |
602 | 602 | } |
603 | 603 | |
604 | | - // Unstrip the output, because unstrip() is no longer recursive so |
| 604 | + // Unstrip the output, because unstrip() is no longer recursive so |
605 | 605 | // it won't do it itself |
606 | 606 | $output = $this->unstrip( $output, $state ); |
607 | 607 | |
— | — | @@ -632,7 +632,7 @@ |
633 | 633 | * always call unstripNoWiki() after this one |
634 | 634 | * @private |
635 | 635 | */ |
636 | | - function unstrip( $text, &$state ) { |
| 636 | + function unstrip( $text, $state ) { |
637 | 637 | if ( !isset( $state['general'] ) ) { |
638 | 638 | return $text; |
639 | 639 | } |
— | — | @@ -649,7 +649,7 @@ |
650 | 650 | * |
651 | 651 | * @private |
652 | 652 | */ |
653 | | - function unstripNoWiki( $text, &$state ) { |
| 653 | + function unstripNoWiki( $text, $state ) { |
654 | 654 | if ( !isset( $state['nowiki'] ) ) { |
655 | 655 | return $text; |
656 | 656 | } |
— | — | @@ -658,7 +658,7 @@ |
659 | 659 | # TODO: good candidate for FSS |
660 | 660 | $text = strtr( $text, $state['nowiki'] ); |
661 | 661 | wfProfileOut( __METHOD__ ); |
662 | | - |
| 662 | + |
663 | 663 | return $text; |
664 | 664 | } |
665 | 665 | |
— | — | @@ -806,6 +806,7 @@ |
807 | 807 | { |
808 | 808 | $x = trim ( $x ) ; |
809 | 809 | $fc = substr ( $x , 0 , 1 ) ; |
| 810 | + $matches = array(); |
810 | 811 | if ( preg_match( '/^(:*)\{\|(.*)$/', $x, $matches ) ) { |
811 | 812 | $indent_level = strlen( $matches[1] ); |
812 | 813 | |
— | — | @@ -879,10 +880,15 @@ |
880 | 881 | |
881 | 882 | $l = array_pop ( $ltd ) ; |
882 | 883 | if ( array_pop ( $td ) ) $z = '</'.$l.'>' . $z ; |
883 | | - if ( $fc == '|' ) $l = 'td' ; |
884 | | - else if ( $fc == '!' ) $l = 'th' ; |
885 | | - else if ( $fc == '+' ) $l = 'caption' ; |
886 | | - else $l = '' ; |
| 884 | + if ( $fc == '|' ) { |
| 885 | + $l = 'td' ; |
| 886 | + } else if ( $fc == '!' ) { |
| 887 | + $l = 'th' ; |
| 888 | + } else if ( $fc == '+' ) { |
| 889 | + $l = 'caption' ; |
| 890 | + } else { |
| 891 | + $l = '' ; |
| 892 | + } |
887 | 893 | array_push ( $ltd , $l ) ; |
888 | 894 | |
889 | 895 | # Cell parameters |
— | — | @@ -935,6 +941,7 @@ |
936 | 942 | wfProfileIn( $fname ); |
937 | 943 | |
938 | 944 | # Hook to suspend the parser in this state |
| 945 | + $x =& $this->mStripState; // FIXME: Please check that this initialization is correct. |
939 | 946 | if ( !wfRunHooks( 'ParserBeforeInternalParse', array( &$this, &$text, &$x ) ) ) { |
940 | 947 | wfProfileOut( $fname ); |
941 | 948 | return $text ; |
— | — | @@ -987,7 +994,7 @@ |
988 | 995 | */ |
989 | 996 | function &doMagicLinks( &$text ) { |
990 | 997 | wfProfileIn( __METHOD__ ); |
991 | | - $text = preg_replace_callback( |
| 998 | + $text = preg_replace_callback( |
992 | 999 | '!(?: # Start cases |
993 | 1000 | <a.*?</a> | # Skip link text |
994 | 1001 | <.*?> | # Skip stuff inside HTML elements |
— | — | @@ -995,7 +1002,7 @@ |
996 | 1003 | ISBN\s+([0-9Xx-]+) # ISBN, capture number as m[2] |
997 | 1004 | )!x', array( &$this, 'magicLinkCallback' ), $text ); |
998 | 1005 | wfProfileOut( __METHOD__ ); |
999 | | - return $text; |
| 1006 | + return $text; |
1000 | 1007 | } |
1001 | 1008 | |
1002 | 1009 | function magicLinkCallback( $m ) { |
— | — | @@ -1004,7 +1011,7 @@ |
1005 | 1012 | return $m[0]; |
1006 | 1013 | } elseif ( substr( $m[0], 0, 4 ) == 'ISBN' ) { |
1007 | 1014 | $isbn = $m[2]; |
1008 | | - $num = strtr( $isbn, array( |
| 1015 | + $num = strtr( $isbn, array( |
1009 | 1016 | '-' => '', |
1010 | 1017 | ' ' => '', |
1011 | 1018 | 'x' => 'X', |
— | — | @@ -1023,10 +1030,10 @@ |
1024 | 1031 | $urlmsg = 'pubmedurl'; |
1025 | 1032 | $id = $m[1]; |
1026 | 1033 | } else { |
1027 | | - throw new MWException( __METHOD__.': unrecognised match type "' . |
| 1034 | + throw new MWException( __METHOD__.': unrecognised match type "' . |
1028 | 1035 | substr($m[0], 0, 20 ) . '"' ); |
1029 | 1036 | } |
1030 | | - |
| 1037 | + |
1031 | 1038 | $url = wfMsg( $urlmsg, $id); |
1032 | 1039 | $sk =& $this->mOptions->getSkin(); |
1033 | 1040 | $la = $sk->getExternalLinkAttributes( $url, $keyword.$id ); |
— | — | @@ -1106,9 +1113,9 @@ |
1107 | 1114 | } |
1108 | 1115 | # Count the number of occurrences of bold and italics mark-ups. |
1109 | 1116 | # We are not counting sequences of five apostrophes. |
1110 | | - if ( strlen( $arr[$i] ) == 2 ) $numitalics++; else |
1111 | | - if ( strlen( $arr[$i] ) == 3 ) $numbold++; else |
1112 | | - if ( strlen( $arr[$i] ) == 5 ) { $numitalics++; $numbold++; } |
| 1117 | + if ( strlen( $arr[$i] ) == 2 ) { $numitalics++; } |
| 1118 | + else if ( strlen( $arr[$i] ) == 3 ) { $numbold++; } |
| 1119 | + else if ( strlen( $arr[$i] ) == 5 ) { $numitalics++; $numbold++; } |
1113 | 1120 | } |
1114 | 1121 | $i++; |
1115 | 1122 | } |
— | — | @@ -1264,6 +1271,7 @@ |
1265 | 1272 | # The characters '<' and '>' (which were escaped by |
1266 | 1273 | # removeHTMLtags()) should not be included in |
1267 | 1274 | # URLs, per RFC 2396. |
| 1275 | + $m2 = array(); |
1268 | 1276 | if (preg_match('/&(lt|gt);/', $url, $m2, PREG_OFFSET_CAPTURE)) { |
1269 | 1277 | $text = substr($url, $m2[0][1]) . ' ' . $text; |
1270 | 1278 | $url = substr($url, 0, $m2[0][1]); |
— | — | @@ -1299,7 +1307,7 @@ |
1300 | 1308 | } |
1301 | 1309 | |
1302 | 1310 | $text = $wgContLang->markNoConversion($text); |
1303 | | - |
| 1311 | + |
1304 | 1312 | $url = Sanitizer::cleanUrl( $url ); |
1305 | 1313 | |
1306 | 1314 | # Process the trail (i.e. everything after this link up until start of the next link), |
— | — | @@ -1342,6 +1350,7 @@ |
1343 | 1351 | $protocol = $bits[$i++]; |
1344 | 1352 | $remainder = $bits[$i++]; |
1345 | 1353 | |
| 1354 | + $m = array(); |
1346 | 1355 | if ( preg_match( '/^('.EXT_LINK_URL_CLASS.'+)(.*)$/s', $remainder, $m ) ) { |
1347 | 1356 | # Found some characters after the protocol that look promising |
1348 | 1357 | $url = $protocol . $m[1]; |
— | — | @@ -1349,10 +1358,10 @@ |
1350 | 1359 | |
1351 | 1360 | # special case: handle urls as url args: |
1352 | 1361 | # http://www.example.com/foo?=http://www.example.com/bar |
1353 | | - if(strlen($trail) == 0 && |
| 1362 | + if(strlen($trail) == 0 && |
1354 | 1363 | isset($bits[$i]) && |
1355 | 1364 | preg_match('/^'. wfUrlProtocols() . '$/S', $bits[$i]) && |
1356 | | - preg_match( '/^('.EXT_LINK_URL_CLASS.'+)(.*)$/s', $bits[$i + 1], $m )) |
| 1365 | + preg_match( '/^('.EXT_LINK_URL_CLASS.'+)(.*)$/s', $bits[$i + 1], $m )) |
1357 | 1366 | { |
1358 | 1367 | # add protocol, arg |
1359 | 1368 | $url .= $bits[$i] . $m[1]; # protocol, url as arg to previous link |
— | — | @@ -1363,6 +1372,7 @@ |
1364 | 1373 | # The characters '<' and '>' (which were escaped by |
1365 | 1374 | # removeHTMLtags()) should not be included in |
1366 | 1375 | # URLs, per RFC 2396. |
| 1376 | + $m2 = array(); |
1367 | 1377 | if (preg_match('/&(lt|gt);/', $url, $m2, PREG_OFFSET_CAPTURE)) { |
1368 | 1378 | $trail = substr($url, $m2[0][1]) . $trail; |
1369 | 1379 | $url = substr($url, 0, $m2[0][1]); |
— | — | @@ -1498,6 +1508,7 @@ |
1499 | 1509 | $nottalk = !$this->mTitle->isTalkPage(); |
1500 | 1510 | |
1501 | 1511 | if ( $useLinkPrefixExtension ) { |
| 1512 | + $m = array(); |
1502 | 1513 | if ( preg_match( $e2, $s, $m ) ) { |
1503 | 1514 | $first_prefix = $m[2]; |
1504 | 1515 | } else { |
— | — | @@ -1543,10 +1554,10 @@ |
1544 | 1555 | # Still some problems for cases where the ] is meant to be outside punctuation, |
1545 | 1556 | # and no image is in sight. See bug 2095. |
1546 | 1557 | # |
1547 | | - if( $text !== '' && |
1548 | | - substr( $m[3], 0, 1 ) === ']' && |
1549 | | - strpos($text, '[') !== false |
1550 | | - ) |
| 1558 | + if( $text !== '' && |
| 1559 | + substr( $m[3], 0, 1 ) === ']' && |
| 1560 | + strpos($text, '[') !== false |
| 1561 | + ) |
1551 | 1562 | { |
1552 | 1563 | $text .= ']'; # so that replaceExternalLinks($text) works later |
1553 | 1564 | $m[3] = substr( $m[3], 1 ); |
— | — | @@ -1605,7 +1616,7 @@ |
1606 | 1617 | $ns = $nt->getNamespace(); |
1607 | 1618 | $iw = $nt->getInterWiki(); |
1608 | 1619 | wfProfileOut( "$fname-title" ); |
1609 | | - |
| 1620 | + |
1610 | 1621 | if ($might_be_img) { # if this is actually an invalid link |
1611 | 1622 | wfProfileIn( "$fname-might_be_img" ); |
1612 | 1623 | if ($ns == NS_IMAGE && $noforce) { #but might be an image |
— | — | @@ -2326,9 +2337,11 @@ |
2327 | 2338 | * expensive to check many times. |
2328 | 2339 | */ |
2329 | 2340 | static $varCache = array(); |
2330 | | - if ( wfRunHooks( 'ParserGetVariableValueVarCache', array( &$this, &$varCache ) ) ) |
2331 | | - if ( isset( $varCache[$index] ) ) |
| 2341 | + if ( wfRunHooks( 'ParserGetVariableValueVarCache', array( &$this, &$varCache ) ) ) { |
| 2342 | + if ( isset( $varCache[$index] ) ) { |
2332 | 2343 | return $varCache[$index]; |
| 2344 | + } |
| 2345 | + } |
2333 | 2346 | |
2334 | 2347 | $ts = time(); |
2335 | 2348 | wfRunHooks( 'ParserGetVariableValueTs', array( &$this, &$ts ) ); |
— | — | @@ -2543,7 +2556,7 @@ |
2544 | 2557 | $lastOpeningBrace = -1; # last not closed parentheses |
2545 | 2558 | |
2546 | 2559 | $validOpeningBraces = implode( '', array_keys( $callbacks ) ); |
2547 | | - |
| 2560 | + |
2548 | 2561 | $i = 0; |
2549 | 2562 | while ( $i < strlen( $text ) ) { |
2550 | 2563 | # Find next opening brace, closing brace or pipe |
— | — | @@ -2597,13 +2610,13 @@ |
2598 | 2611 | $maxCount = $openingBraceStack[$lastOpeningBrace]['count']; |
2599 | 2612 | $count = strspn( $text, $text[$i], $i, $maxCount ); |
2600 | 2613 | |
2601 | | - # check for maximum matching characters (if there are 5 closing |
| 2614 | + # check for maximum matching characters (if there are 5 closing |
2602 | 2615 | # characters, we will probably need only 3 - depending on the rules) |
2603 | 2616 | $matchingCount = 0; |
2604 | 2617 | $matchingCallback = null; |
2605 | 2618 | $cbType = $callbacks[$openingBraceStack[$lastOpeningBrace]['brace']]; |
2606 | 2619 | if ( $count > $cbType['max'] ) { |
2607 | | - # The specified maximum exists in the callback array, unless the caller |
| 2620 | + # The specified maximum exists in the callback array, unless the caller |
2608 | 2621 | # has made an error |
2609 | 2622 | $matchingCount = $cbType['max']; |
2610 | 2623 | } else { |
— | — | @@ -2624,12 +2637,12 @@ |
2625 | 2638 | |
2626 | 2639 | # let's set a title or last part (if '|' was found) |
2627 | 2640 | if (null === $openingBraceStack[$lastOpeningBrace]['parts']) { |
2628 | | - $openingBraceStack[$lastOpeningBrace]['title'] = |
2629 | | - substr($text, $openingBraceStack[$lastOpeningBrace]['partStart'], |
| 2641 | + $openingBraceStack[$lastOpeningBrace]['title'] = |
| 2642 | + substr($text, $openingBraceStack[$lastOpeningBrace]['partStart'], |
2630 | 2643 | $i - $openingBraceStack[$lastOpeningBrace]['partStart']); |
2631 | 2644 | } else { |
2632 | | - $openingBraceStack[$lastOpeningBrace]['parts'][] = |
2633 | | - substr($text, $openingBraceStack[$lastOpeningBrace]['partStart'], |
| 2645 | + $openingBraceStack[$lastOpeningBrace]['parts'][] = |
| 2646 | + substr($text, $openingBraceStack[$lastOpeningBrace]['partStart'], |
2634 | 2647 | $i - $openingBraceStack[$lastOpeningBrace]['partStart']); |
2635 | 2648 | } |
2636 | 2649 | |
— | — | @@ -2679,13 +2692,13 @@ |
2680 | 2693 | } elseif ( $found == 'pipe' ) { |
2681 | 2694 | # lets set a title if it is a first separator, or next part otherwise |
2682 | 2695 | if (null === $openingBraceStack[$lastOpeningBrace]['parts']) { |
2683 | | - $openingBraceStack[$lastOpeningBrace]['title'] = |
2684 | | - substr($text, $openingBraceStack[$lastOpeningBrace]['partStart'], |
| 2696 | + $openingBraceStack[$lastOpeningBrace]['title'] = |
| 2697 | + substr($text, $openingBraceStack[$lastOpeningBrace]['partStart'], |
2685 | 2698 | $i - $openingBraceStack[$lastOpeningBrace]['partStart']); |
2686 | 2699 | $openingBraceStack[$lastOpeningBrace]['parts'] = array(); |
2687 | 2700 | } else { |
2688 | | - $openingBraceStack[$lastOpeningBrace]['parts'][] = |
2689 | | - substr($text, $openingBraceStack[$lastOpeningBrace]['partStart'], |
| 2701 | + $openingBraceStack[$lastOpeningBrace]['parts'][] = |
| 2702 | + substr($text, $openingBraceStack[$lastOpeningBrace]['partStart'], |
2690 | 2703 | $i - $openingBraceStack[$lastOpeningBrace]['partStart']); |
2691 | 2704 | } |
2692 | 2705 | $openingBraceStack[$lastOpeningBrace]['partStart'] = ++$i; |
— | — | @@ -2731,15 +2744,15 @@ |
2732 | 2745 | $braceCallbacks[3] = array( &$this, 'argSubstitution' ); |
2733 | 2746 | } |
2734 | 2747 | if ( $braceCallbacks ) { |
2735 | | - $callbacks = array( |
| 2748 | + $callbacks = array( |
2736 | 2749 | '{' => array( |
2737 | 2750 | 'end' => '}', |
2738 | 2751 | 'cb' => $braceCallbacks, |
2739 | 2752 | 'min' => $argsOnly ? 3 : 2, |
2740 | 2753 | 'max' => isset( $braceCallbacks[3] ) ? 3 : 2, |
2741 | 2754 | ), |
2742 | | - '[' => array( |
2743 | | - 'end' => ']', |
| 2755 | + '[' => array( |
| 2756 | + 'end' => ']', |
2744 | 2757 | 'cb' => array(2=>null), |
2745 | 2758 | 'min' => 2, |
2746 | 2759 | 'max' => 2, |
— | — | @@ -2801,7 +2814,7 @@ |
2802 | 2815 | * @private |
2803 | 2816 | */ |
2804 | 2817 | function braceSubstitution( $piece ) { |
2805 | | - global $wgContLang, $wgLang, $wgAllowDisplayTitle, $action; |
| 2818 | + global $wgContLang, $wgLang, $wgAllowDisplayTitle; |
2806 | 2819 | $fname = __METHOD__ /*. '-L' . count( $this->mArgStack )*/; |
2807 | 2820 | wfProfileIn( $fname ); |
2808 | 2821 | wfProfileIn( __METHOD__.'-setup' ); |
— | — | @@ -2820,7 +2833,7 @@ |
2821 | 2834 | |
2822 | 2835 | $linestart = ''; |
2823 | 2836 | |
2824 | | - |
| 2837 | + |
2825 | 2838 | # $part1 is the bit before the first |, and must contain only title characters |
2826 | 2839 | # $args is a list of arguments, starting from index 0, not including $part1 |
2827 | 2840 | |
— | — | @@ -2838,7 +2851,6 @@ |
2839 | 2852 | } |
2840 | 2853 | |
2841 | 2854 | $args = (null == $piece['parts']) ? array() : $piece['parts']; |
2842 | | - $argc = count( $args ); |
2843 | 2855 | wfProfileOut( __METHOD__.'-setup' ); |
2844 | 2856 | |
2845 | 2857 | # SUBST |
— | — | @@ -2868,7 +2880,7 @@ |
2869 | 2881 | $mwMsg =& MagicWord::get( 'msg' ); |
2870 | 2882 | $mwMsg->matchStartAndRemove( $part1 ); |
2871 | 2883 | } |
2872 | | - |
| 2884 | + |
2873 | 2885 | # Check for RAW: |
2874 | 2886 | $mwRaw =& MagicWord::get( 'raw' ); |
2875 | 2887 | if ( $mwRaw->matchStartAndRemove( $part1 ) ) { |
— | — | @@ -2880,7 +2892,7 @@ |
2881 | 2893 | # Parser functions |
2882 | 2894 | if ( !$found ) { |
2883 | 2895 | wfProfileIn( __METHOD__ . '-pfunc' ); |
2884 | | - |
| 2896 | + |
2885 | 2897 | $colonPos = strpos( $part1, ':' ); |
2886 | 2898 | if ( $colonPos !== false ) { |
2887 | 2899 | # Case sensitive functions |
— | — | @@ -3062,6 +3074,7 @@ |
3063 | 3075 | if ( !$noparse ) { |
3064 | 3076 | # If there are any <onlyinclude> tags, only include them |
3065 | 3077 | if ( in_string( '<onlyinclude>', $text ) && in_string( '</onlyinclude>', $text ) ) { |
| 3078 | + $m = array(); |
3066 | 3079 | preg_match_all( '/<onlyinclude>(.*?)\n?<\/onlyinclude>/s', $text, $m ); |
3067 | 3080 | $text = ''; |
3068 | 3081 | foreach ($m[1] as $piece) |
— | — | @@ -3084,7 +3097,7 @@ |
3085 | 3098 | |
3086 | 3099 | # If the template begins with a table or block-level |
3087 | 3100 | # element, it should be treated as beginning a new line. |
3088 | | - if (!$piece['lineStart'] && preg_match('/^({\\||:|;|#|\*)/', $text)) /*}*/{ |
| 3101 | + if (!$piece['lineStart'] && preg_match('/^({\\||:|;|#|\*)/', $text)) /*}*/{ |
3089 | 3102 | $text = "\n" . $text; |
3090 | 3103 | } |
3091 | 3104 | } elseif ( !$noargs ) { |
— | — | @@ -3135,6 +3148,7 @@ |
3136 | 3149 | $text .= $hl; |
3137 | 3150 | continue; |
3138 | 3151 | } |
| 3152 | + $m2 = array(); |
3139 | 3153 | preg_match('/^(={1,6})(.*?)(={1,6})\s*?$/m', $hl, $m2); |
3140 | 3154 | $text .= $m2[1] . $m2[2] . "<!--MWTEMPLATESECTION=" |
3141 | 3155 | . $encodedname . "&" . base64_encode("$nsec") . "-->" . $m2[3]; |
— | — | @@ -3242,7 +3256,7 @@ |
3243 | 3257 | |
3244 | 3258 | if ( array_key_exists( $arg, $inputArgs ) ) { |
3245 | 3259 | $text = $inputArgs[$arg]; |
3246 | | - } else if (($this->mOutputType == OT_HTML || $this->mOutputType == OT_PREPROCESS ) && |
| 3260 | + } else if (($this->mOutputType == OT_HTML || $this->mOutputType == OT_PREPROCESS ) && |
3247 | 3261 | null != $matches['parts'] && count($matches['parts']) > 0) { |
3248 | 3262 | $text = $matches['parts'][0]; |
3249 | 3263 | } |
— | — | @@ -3337,6 +3351,7 @@ |
3338 | 3352 | |
3339 | 3353 | # Get all headlines for numbering them and adding funky stuff like [edit] |
3340 | 3354 | # links - this is for later, but we need the number of headlines right now |
| 3355 | + $matches = array(); |
3341 | 3356 | $numMatches = preg_match_all( '/<H([1-6])(.*?'.'>)(.*?)<\/H[1-6] *>/i', $text, $matches ); |
3342 | 3357 | |
3343 | 3358 | # if there are fewer than 4 headlines in the article, do not show TOC |
— | — | @@ -3388,7 +3403,7 @@ |
3389 | 3404 | $templatetitle = ''; |
3390 | 3405 | $templatesection = 0; |
3391 | 3406 | $numbering = ''; |
3392 | | - |
| 3407 | + $mat = array(); |
3393 | 3408 | if (preg_match("/<!--MWTEMPLATESECTION=([^&]+)&([^_]+)-->/", $headline, $mat)) { |
3394 | 3409 | $istemplate = 1; |
3395 | 3410 | $templatetitle = base64_decode($mat[1]); |
— | — | @@ -3570,7 +3585,7 @@ |
3571 | 3586 | * @return string the altered wiki markup |
3572 | 3587 | * @public |
3573 | 3588 | */ |
3574 | | - function preSaveTransform( $text, &$title, &$user, $options, $clearState = true ) { |
| 3589 | + function preSaveTransform( $text, &$title, $user, $options, $clearState = true ) { |
3575 | 3590 | $this->mOptions = $options; |
3576 | 3591 | $this->mTitle =& $title; |
3577 | 3592 | $this->setOutputType( OT_WIKI ); |
— | — | @@ -3595,7 +3610,7 @@ |
3596 | 3611 | * Pre-save transform helper function |
3597 | 3612 | * @private |
3598 | 3613 | */ |
3599 | | - function pstPass2( $text, &$stripState, &$user ) { |
| 3614 | + function pstPass2( $text, &$stripState, $user ) { |
3600 | 3615 | global $wgContLang, $wgLocaltimezone; |
3601 | 3616 | |
3602 | 3617 | /* Note: This is the timestamp saved as hardcoded wikitext to |
— | — | @@ -3643,6 +3658,7 @@ |
3644 | 3659 | $text = preg_replace( $p3, '[[\\1\\2\\3\\4|\\2]]', $text ); |
3645 | 3660 | |
3646 | 3661 | $t = $this->mTitle->getText(); |
| 3662 | + $m = array(); |
3647 | 3663 | if ( preg_match( "/^($nc+:|)$tc+?( \\($tc+\\))$/", $t, $m ) ) { |
3648 | 3664 | $text = preg_replace( $p2, "[[$m[1]\\1$m[2]|\\1]]", $text ); |
3649 | 3665 | } elseif ( preg_match( "/^($nc+:|)$tc+?(, $tc+|)$/", $t, $m ) && '' != "$m[1]$m[2]" ) { |
— | — | @@ -3820,10 +3836,10 @@ |
3821 | 3837 | * The callback function should have the form: |
3822 | 3838 | * function myParserFunction( &$parser, $arg1, $arg2, $arg3 ) { ... } |
3823 | 3839 | * |
3824 | | - * The callback may either return the text result of the function, or an array with the text |
3825 | | - * in element 0, and a number of flags in the other elements. The names of the flags are |
| 3840 | + * The callback may either return the text result of the function, or an array with the text |
| 3841 | + * in element 0, and a number of flags in the other elements. The names of the flags are |
3826 | 3842 | * specified in the keys. Valid flags are: |
3827 | | - * found The text returned is valid, stop processing the template. This |
| 3843 | + * found The text returned is valid, stop processing the template. This |
3828 | 3844 | * is on by default. |
3829 | 3845 | * nowiki Wiki markup in the return value should be escaped |
3830 | 3846 | * noparse Unsafe HTML tags should not be stripped, etc. |
— | — | @@ -3834,7 +3850,7 @@ |
3835 | 3851 | * |
3836 | 3852 | * @param string $id The magic word ID |
3837 | 3853 | * @param mixed $callback The callback function (and object) to use |
3838 | | - * @param integer $flags a combination of the following flags: |
| 3854 | + * @param integer $flags a combination of the following flags: |
3839 | 3855 | * SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}} |
3840 | 3856 | * |
3841 | 3857 | * @return The old callback function for this name, if any |
— | — | @@ -3890,7 +3906,7 @@ |
3891 | 3907 | function replaceLinkHolders( &$text, $options = 0 ) { |
3892 | 3908 | global $wgUser; |
3893 | 3909 | global $wgOutputReplace; |
3894 | | - global $wgContLang, $wgLanguageCode; |
| 3910 | + global $wgContLang; |
3895 | 3911 | |
3896 | 3912 | $fname = 'Parser::replaceLinkHolders'; |
3897 | 3913 | wfProfileIn( $fname ); |
— | — | @@ -3911,6 +3927,7 @@ |
3912 | 3928 | |
3913 | 3929 | # Generate query |
3914 | 3930 | $query = false; |
| 3931 | + $current = null; |
3915 | 3932 | foreach ( $this->mLinkHolders['namespaces'] as $key => $ns ) { |
3916 | 3933 | # Make title object |
3917 | 3934 | $title = $this->mLinkHolders['titles'][$key]; |
— | — | @@ -3983,7 +4000,7 @@ |
3984 | 4001 | |
3985 | 4002 | # Do a second query for different language variants of links (if needed) |
3986 | 4003 | if($wgContLang->hasVariants()){ |
3987 | | - $linkBatch = new LinkBatch(); |
| 4004 | + $linkBatch = new LinkBatch(); |
3988 | 4005 | $variantMap = array(); // maps $pdbkey_Variant => $pdbkey_original |
3989 | 4006 | |
3990 | 4007 | // Add variants of links to link batch |
— | — | @@ -4007,8 +4024,8 @@ |
4008 | 4025 | } |
4009 | 4026 | } |
4010 | 4027 | } |
4011 | | - |
4012 | 4028 | |
| 4029 | + |
4013 | 4030 | if(!$linkBatch->isEmpty()){ |
4014 | 4031 | // construct query |
4015 | 4032 | $titleClause = $linkBatch->constructSet('page', $dbr); |
— | — | @@ -4036,7 +4053,7 @@ |
4037 | 4054 | $holderKeys = $variantMap[$varPdbk]; |
4038 | 4055 | |
4039 | 4056 | // loop over link holders |
4040 | | - foreach($holderKeys as $key){ |
| 4057 | + foreach($holderKeys as $key){ |
4041 | 4058 | $title = $this->mLinkHolders['titles'][$key]; |
4042 | 4059 | if ( is_null( $title ) ) continue; |
4043 | 4060 | |
— | — | @@ -4046,7 +4063,7 @@ |
4047 | 4064 | // found link in some of the variants, replace the link holder data |
4048 | 4065 | $this->mLinkHolders['titles'][$key] = $variantTitle; |
4049 | 4066 | $this->mLinkHolders['dbkeys'][$key] = $variantTitle->getDBkey(); |
4050 | | - |
| 4067 | + |
4051 | 4068 | // set pdbk and colour |
4052 | 4069 | $pdbks[$key] = $varPdbk; |
4053 | 4070 | if ( $threshold > 0 ) { |
— | — | @@ -4056,10 +4073,10 @@ |
4057 | 4074 | } else { |
4058 | 4075 | $colours[$varPdbk] = 2; |
4059 | 4076 | } |
4060 | | - } |
| 4077 | + } |
4061 | 4078 | else { |
4062 | 4079 | $colours[$varPdbk] = 1; |
4063 | | - } |
| 4080 | + } |
4064 | 4081 | } |
4065 | 4082 | } |
4066 | 4083 | } |
— | — | @@ -4167,7 +4184,7 @@ |
4168 | 4185 | /** |
4169 | 4186 | * Tag hook handler for 'pre'. |
4170 | 4187 | */ |
4171 | | - function renderPreTag( $text, $attribs, $parser ) { |
| 4188 | + function renderPreTag( $text, $attribs ) { |
4172 | 4189 | // Backwards-compatibility hack |
4173 | 4190 | $content = preg_replace( '!<nowiki>(.*?)</nowiki>!is', '\\1', $text ); |
4174 | 4191 | |
— | — | @@ -4200,6 +4217,7 @@ |
4201 | 4218 | foreach ( $lines as $line ) { |
4202 | 4219 | # match lines like these: |
4203 | 4220 | # Image:someimage.jpg|This is some image |
| 4221 | + $matches = array(); |
4204 | 4222 | preg_match( "/^([^|]+)(\\|(.*))?$/", $line, $matches ); |
4205 | 4223 | # Skip empty lines |
4206 | 4224 | if ( count( $matches ) == 0 ) { |
— | — | @@ -4238,7 +4256,7 @@ |
4239 | 4257 | /** |
4240 | 4258 | * Parse image options text and use it to make an image |
4241 | 4259 | */ |
4242 | | - function makeImage( &$nt, $options ) { |
| 4260 | + function makeImage( $nt, $options ) { |
4243 | 4261 | global $wgUseImageResize, $wgDjvuRenderer; |
4244 | 4262 | |
4245 | 4263 | $align = ''; |
— | — | @@ -4270,7 +4288,7 @@ |
4271 | 4289 | $page = null; |
4272 | 4290 | $manual_thumb = '' ; |
4273 | 4291 | |
4274 | | - foreach( $part as $key => $val ) { |
| 4292 | + foreach( $part as $val ) { |
4275 | 4293 | if ( $wgUseImageResize && ! is_null( $mwThumb->matchVariableStartToEnd($val) ) ) { |
4276 | 4294 | $thumb=true; |
4277 | 4295 | } elseif ( ! is_null( $match = $mwManualThumb->matchVariableStartToEnd($val) ) ) { |
— | — | @@ -4296,6 +4314,7 @@ |
4297 | 4315 | } elseif ( $wgUseImageResize && ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) { |
4298 | 4316 | wfDebug( "img_width match: $match\n" ); |
4299 | 4317 | # $match is the image width in pixels |
| 4318 | + $m = array(); |
4300 | 4319 | if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $match, $m ) ) { |
4301 | 4320 | $width = intval( $m[1] ); |
4302 | 4321 | $height = intval( $m[2] ); |
— | — | @@ -4314,7 +4333,7 @@ |
4315 | 4334 | # make sure there are no placeholders in thumbnail attributes |
4316 | 4335 | # that are later expanded to html- so expand them now and |
4317 | 4336 | # remove the tags |
4318 | | - $alt = $this->unstrip($alt, $this->mStripState); |
| 4337 | + $alt = $this->unstrip($alt, $this->mStripState); |
4319 | 4338 | $alt = Sanitizer::stripAllTags( $alt ); |
4320 | 4339 | |
4321 | 4340 | # Linker does the rest |
— | — | @@ -4594,7 +4613,7 @@ |
4595 | 4614 | function addImage( $name ) { $this->mImages[$name] = 1; } |
4596 | 4615 | function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; } |
4597 | 4616 | function addExternalLink( $url ) { $this->mExternalLinks[$url] = 1; } |
4598 | | - |
| 4617 | + |
4599 | 4618 | function setNewSection( $value ) { |
4600 | 4619 | $this->mNewSection = (bool)$value; |
4601 | 4620 | } |
— | — | @@ -4650,22 +4669,22 @@ |
4651 | 4670 | class ParserOptions |
4652 | 4671 | { |
4653 | 4672 | # All variables are private |
4654 | | - var $mUseTeX; # Use texvc to expand <math> tags |
4655 | | - var $mUseDynamicDates; # Use DateFormatter to format dates |
4656 | | - var $mInterwikiMagic; # Interlanguage links are removed and returned in an array |
4657 | | - var $mAllowExternalImages; # Allow external images inline |
4658 | | - var $mAllowExternalImagesFrom; # If not, any exception? |
4659 | | - var $mSkin; # Reference to the preferred skin |
4660 | | - var $mDateFormat; # Date format index |
4661 | | - var $mEditSection; # Create "edit section" links |
4662 | | - var $mNumberHeadings; # Automatically number headings |
4663 | | - var $mAllowSpecialInclusion; # Allow inclusion of special pages |
4664 | | - var $mTidy; # Ask for tidy cleanup |
4665 | | - var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR |
4666 | | - var $mMaxIncludeSize; # Maximum size of template expansions, in bytes |
4667 | | - var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS |
| 4673 | + private $mUseTeX; # Use texvc to expand <math> tags |
| 4674 | + private $mUseDynamicDates; # Use DateFormatter to format dates |
| 4675 | + private $mInterwikiMagic; # Interlanguage links are removed and returned in an array |
| 4676 | + private $mAllowExternalImages; # Allow external images inline |
| 4677 | + private $mAllowExternalImagesFrom; # If not, any exception? |
| 4678 | + private $mSkin; # Reference to the preferred skin |
| 4679 | + private $mDateFormat; # Date format index |
| 4680 | + private $mEditSection; # Create "edit section" links |
| 4681 | + private $mNumberHeadings; # Automatically number headings |
| 4682 | + private $mAllowSpecialInclusion; # Allow inclusion of special pages |
| 4683 | + private $mTidy; # Ask for tidy cleanup |
| 4684 | + private $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR |
| 4685 | + private $mMaxIncludeSize; # Maximum size of template expansions, in bytes |
| 4686 | + private $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS |
4668 | 4687 | |
4669 | | - var $mUser; # Stored user object, just used to initialise the skin |
| 4688 | + private $mUser; # Stored user object, just used to initialise the skin |
4670 | 4689 | |
4671 | 4690 | function getUseTeX() { return $this->mUseTeX; } |
4672 | 4691 | function getUseDynamicDates() { return $this->mUseDynamicDates; } |
— | — | @@ -4687,7 +4706,7 @@ |
4688 | 4707 | return $this->mSkin; |
4689 | 4708 | } |
4690 | 4709 | |
4691 | | - function getDateFormat() { |
| 4710 | + function getDateFormat() { |
4692 | 4711 | if ( !isset( $this->mDateFormat ) ) { |
4693 | 4712 | $this->mDateFormat = $this->mUser->getDatePreference(); |
4694 | 4713 | } |
— | — | @@ -4704,7 +4723,7 @@ |
4705 | 4724 | function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); } |
4706 | 4725 | function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); } |
4707 | 4726 | function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); } |
4708 | | - function setSkin( &$x ) { $this->mSkin =& $x; } |
| 4727 | + function setSkin( $x ) { $this->mSkin = $x; } |
4709 | 4728 | function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage, $x); } |
4710 | 4729 | function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize, $x ); } |
4711 | 4730 | function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments, $x ); } |
— | — | @@ -4881,7 +4900,7 @@ |
4882 | 4901 | function wfRevisionTimestamp( $id ) { |
4883 | 4902 | global $wgContLang; |
4884 | 4903 | $fname = 'wfRevisionTimestamp'; |
4885 | | - |
| 4904 | + |
4886 | 4905 | wfProfileIn( $fname ); |
4887 | 4906 | $dbr =& wfGetDB( DB_SLAVE ); |
4888 | 4907 | $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', |