Skip to content

Commit

Permalink
L10N translation not found event: protect against reentrance.
Browse files Browse the repository at this point in the history
  • Loading branch information
rotdrop committed Mar 22, 2022
1 parent ff731b7 commit 79f1728
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/private/L10N/L10NString.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -64,14 +67,16 @@ 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();
$locale = $this->l10n->getLocaleCode();
$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)) {
Expand Down

0 comments on commit 79f1728

Please sign in to comment.