https://www.mediawiki.org/wiki/Special:Code/MediaWiki/106258

Revision: 106258
Author:   catrope
Date:     2011-12-14 22:16:42 +0000 (Wed, 14 Dec 2011)
Log Message:
-----------
1.18wmf1: MFT r105377

Modified Paths:
--------------
    branches/wmf/1.18wmf1/includes/Preferences.php
    branches/wmf/1.18wmf1/includes/parser/Parser.php
    branches/wmf/1.18wmf1/tests/phpunit/includes/ExtraParserTest.php

Modified: branches/wmf/1.18wmf1/includes/Preferences.php
===================================================================
--- branches/wmf/1.18wmf1/includes/Preferences.php      2011-12-14 22:15:01 UTC 
(rev 106257)
+++ branches/wmf/1.18wmf1/includes/Preferences.php      2011-12-14 22:16:42 UTC 
(rev 106258)
@@ -1184,12 +1184,12 @@
         * @return string
         */
        static function cleanSignature( $signature, $alldata ) {
-               global $wgParser;
                if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) {
+                       global $wgParser;
                        $signature = $wgParser->cleanSig( $signature );
                } else {
                        // When no fancy sig used, make sure ~{3,5} get removed.
-                       $signature = $wgParser->cleanSigInSig( $signature );
+                       $signature = Parser::cleanSigInSig( $signature );
                }
 
                return $signature;

Modified: branches/wmf/1.18wmf1/includes/parser/Parser.php
===================================================================
--- branches/wmf/1.18wmf1/includes/parser/Parser.php    2011-12-14 22:15:01 UTC 
(rev 106257)
+++ branches/wmf/1.18wmf1/includes/parser/Parser.php    2011-12-14 22:16:42 UTC 
(rev 106258)
@@ -4260,7 +4260,7 @@
                }
 
                # Make sure nickname doesnt get a sig in a sig
-               $nickname = $this->cleanSigInSig( $nickname );
+               $nickname = self::cleanSigInSig( $nickname );
 
                # If we're still here, make it a link to the user page
                $userText = wfEscapeWikiText( $username );
@@ -4290,7 +4290,7 @@
         * @param $parsing Whether we're cleaning (preferences save) or parsing
         * @return String: signature text
         */
-       function cleanSig( $text, $parsing = false ) {
+       public function cleanSig( $text, $parsing = false ) {
                if ( !$parsing ) {
                        global $wgTitle;
                        $this->mOptions = new ParserOptions;
@@ -4311,7 +4311,7 @@
                $substText = '{{' . $substWord->getSynonym( 0 );
 
                $text = preg_replace( $substRegex, $substText, $text );
-               $text = $this->cleanSigInSig( $text );
+               $text = self::cleanSigInSig( $text );
                $dom = $this->preprocessToDom( $text );
                $frame = $this->getPreprocessor()->newFrame();
                $text = $frame->expand( $dom );
@@ -4329,7 +4329,7 @@
         * @param $text String
         * @return String: signature text with /~{3,5}/ removed
         */
-       function cleanSigInSig( $text ) {
+       public static function cleanSigInSig( $text ) {
                $text = preg_replace( '/~{3,5}/', '', $text );
                return $text;
        }

Modified: branches/wmf/1.18wmf1/tests/phpunit/includes/ExtraParserTest.php
===================================================================
--- branches/wmf/1.18wmf1/tests/phpunit/includes/ExtraParserTest.php    
2011-12-14 22:15:01 UTC (rev 106257)
+++ branches/wmf/1.18wmf1/tests/phpunit/includes/ExtraParserTest.php    
2011-12-14 22:16:42 UTC (rev 106258)
@@ -69,14 +69,20 @@
        
        /**
         * cleanSigInSig() just removes tildes
+        * @dataProvider provideStringsForCleanSigInSig
         */
-       function testCleanSigInSig() {
-               $title = Title::newFromText( __FUNCTION__ );
-               $outputText = $this->parser->cleanSigInSig( "{{Foo}} ~~~~" );
-               
-               $this->assertEquals( "{{Foo}} ", $outputText );
+       function testCleanSigInSig( $in, $out ) {
+               $this->assertEquals( Parser::cleanSigInSig( $in), $out );
        }
        
+       function provideStringsForCleanSigInSig() {
+               return array(
+                       array( "{{Foo}} ~~~~", "{{Foo}} " ),
+                       array( "~~~", "" ),
+                       array( "~~~~~", "" ),
+               );
+       }
+       
        function testGetSection() {
                $outputText2 = $this->parser->getSection( "Section 0\n== 
Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 
3\n", 2 );
                $outputText1 = $this->parser->getSection( "Section 0\n== 
Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 
3\n", 1 );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to