From 79f1728754fefb5a2021d206010ba4f8e5298944 Mon Sep 17 00:00:00 2001 From: Claus-Justus Heine Date: Wed, 16 Feb 2022 12:22:50 +0100 Subject: [PATCH] L10N translation not found event: protect against reentrance. --- lib/private/L10N/L10NString.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/private/L10N/L10NString.php b/lib/private/L10N/L10NString.php index 0744c2a7f69d9..fe4aa11184e7f 100644 --- a/lib/private/L10N/L10NString.php +++ b/lib/private/L10N/L10NString.php @@ -43,6 +43,9 @@ class L10NString implements \JsonSerializable { /** @var integer */ protected $count; + /** @var bool */ + static protected $eventLock = false; + /** * @param L10N $l10n * @param string|string[] $text @@ -64,7 +67,8 @@ public function __toString(): string { $identity = $this->text; if (array_key_exists($this->text, $translations)) { $identity = $translations[$this->text]; - } else { + } else if (!self::$eventLock) { + self::$eventLock = true; $text = $this->text; $app = $this->l10n->getAppName(); $language = $this->l10n->getLanguageCode(); @@ -72,6 +76,7 @@ public function __toString(): string { $event = new Events\TranslationNotFound($text, $language, $locale, $app); \OC::$server->query(IEventDispatcher::class)->dispatchTyped($event); //\OCP\Util::writeLog($app, "Translation for ``".$text."'' not found.", ILogger::INFO); + self::$eventLock = false; } if (!$this->pipeCheck($identity)) {