Merge "Fix TitlePermissionTest failures due to test leakage"
[lhc/web/wiklou.git] / includes / exception / MWException.php
index 652a87d..af835e4 100644 (file)
@@ -76,6 +76,7 @@ class MWException extends Exception {
                global $wgSitename;
                $args = array_slice( func_get_args(), 2 );
 
+               // FIXME: Keep logic in sync with MWExceptionRenderer::msg.
                $res = false;
                if ( $this->useMessageCache() ) {
                        try {
@@ -87,7 +88,9 @@ class MWException extends Exception {
                        $res = wfMsgReplaceArgs( $fallback, $args );
                        // If an exception happens inside message rendering,
                        // {{SITENAME}} sometimes won't be replaced.
-                       $res = preg_replace( '/\{\{SITENAME\}\}/', $wgSitename, $res );
+                       $res = strtr( $res, [
+                               '{{SITENAME}}' => $wgSitename,
+                       ] );
                }
                return $res;
        }