Skip to content

Commit

Permalink
Merge pull request #25497 from nextcloud/backport/25487/stable20
Browse files Browse the repository at this point in the history
[stable20] Log deprecation notice of GenericEventWrapper just once
  • Loading branch information
rullzer authored Feb 5, 2021
2 parents fa2ed5b + 61278d2 commit b6ac93d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/private/EventDispatcher/GenericEventWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class GenericEventWrapper extends GenericEvent {
/** @var string */
private $eventName;

/** @var bool */
private $deprecationNoticeLogged = false;

public function __construct(ILogger $logger, string $eventName, ?GenericEvent $event) {
parent::__construct($eventName);
$this->logger = $logger;
Expand All @@ -49,11 +52,16 @@ public function __construct(ILogger $logger, string $eventName, ?GenericEvent $e
}

private function log() {
if ($this->deprecationNoticeLogged) {
return;
}

$class = ($this->event !== null && is_object($this->event)) ? get_class($this->event) : 'null';
$this->logger->info(
'Deprecated event type for {name}: {class} is used',
[ 'name' => $this->eventName, 'class' => $class]
);
$this->deprecationNoticeLogged = true;
}

public function isPropagationStopped(): bool {
Expand Down

0 comments on commit b6ac93d

Please sign in to comment.