diff --git a/src/Sanitize.php b/src/Sanitize.php
index d3a58b5bad..f110bf90f0 100644
--- a/src/Sanitize.php
+++ b/src/Sanitize.php
@@ -174,24 +174,31 @@ class Sanitize
$message = strtr($message, ['<' => '<', '>' => '>']);
}
- /* Interpret bb code */
- $replacePairs = [
- '[em]' => '',
- '[/em]' => '',
- '[strong]' => '',
- '[/strong]' => '',
- '[code]' => '',
- '[/code]' => '',
- '[kbd]' => '',
- '[/kbd]' => '',
- '[br]' => '
',
- '[/a]' => '',
- '[/doc]' => '',
- '[sup]' => '',
- '[/sup]' => '',
- // used in libraries/Util.php
- '[dochelpicon]' => Html\Generator::getImage('b_help', __('Documentation')),
- ];
+ /**
+ * Interpret bb code
+ *
+ * @var array $replacePairs
+ */
+ static $replacePairs = [];
+ if ($replacePairs === []) {
+ $replacePairs = [
+ '[em]' => '',
+ '[/em]' => '',
+ '[strong]' => '',
+ '[/strong]' => '',
+ '[code]' => '',
+ '[/code]' => '',
+ '[kbd]' => '',
+ '[/kbd]' => '',
+ '[br]' => '
',
+ '[/a]' => '',
+ '[/doc]' => '',
+ '[sup]' => '',
+ '[/sup]' => '',
+ // used in libraries/Util.php
+ '[dochelpicon]' => Html\Generator::getImage('b_help', __('Documentation')),
+ ];
+ }
$message = strtr($message, $replacePairs);