From 643b1b40a8f854695ea4e91281bb78c30d3ccd09 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 3 Nov 2016 11:50:44 -0700 Subject: [PATCH] Don't cache replacement patterns in wfEscapeWikitext() during tests 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index bae9c772e3..15a73cfc30 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 = [ '"' => '"', '&' => '&', "'" => ''', '<' => '<', '=' => '=', '>' => '>', '[' => '[', ']' => ']', -- 2.20.1