From: Timo Tijhof Date: Thu, 27 Sep 2018 16:04:48 +0000 (+0100) Subject: exception: Avoid preg_replace for literal swap X-Git-Tag: 1.34.0-rc.0~3972^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=8476ec3cb872c9ef6142c31004a0dff109dcc690;p=lhc%2Fweb%2Fwiklou.git exception: Avoid preg_replace for literal swap Follows-up bbcbcaba3db9. Change-Id: Ie7b76c28ba53668d73a8435c4d2ec91757bd2372 --- diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index 652a87dcfc..ffeafff50e 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -87,7 +87,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; } diff --git a/includes/exception/MWExceptionRenderer.php b/includes/exception/MWExceptionRenderer.php index 1f1cabeae1..503638303f 100644 --- a/includes/exception/MWExceptionRenderer.php +++ b/includes/exception/MWExceptionRenderer.php @@ -205,7 +205,9 @@ class MWExceptionRenderer { $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; }