Don't cache replacement patterns in wfEscapeWikitext() during tests
authorKunal Mehta <legoktm@member.fsf.org>
Thu, 3 Nov 2016 18:50:44 +0000 (11:50 -0700)
committerLegoktm <legoktm.wikipedia@gmail.com>
Fri, 4 Nov 2016 02:27:13 +0000 (02:27 +0000)
Parser tests depend upon being able to change the value of
$wgEnableMagicLinks at runtime, so skip caching the replacement patterns
while parser tests or phpunit tests are being run.

Change-Id: Ic9fe4fe898aa353bdefa2bf8207b77d2ac14887f

includes/GlobalFunctions.php

index bae9c77..15a73cf 100644 (file)
@@ -1670,7 +1670,9 @@ function wfClientAcceptsGzip( $force = false ) {
 function wfEscapeWikiText( $text ) {
        global $wgEnableMagicLinks;
        static $repl = null, $repl2 = null;
-       if ( $repl === null ) {
+       if ( $repl === null || defined( 'MW_PARSER_TEST' ) || defined( 'MW_PHPUNIT_TEST' ) ) {
+               // Tests depend upon being able to change $wgEnableMagicLinks, so don't cache
+               // in those situations
                $repl = [
                        '"' => '&#34;', '&' => '&#38;', "'" => '&#39;', '<' => '&#60;',
                        '=' => '&#61;', '>' => '&#62;', '[' => '&#91;', ']' => '&#93;',