]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix missing parent constructor call and get_class usage in GenericEventWrapper 21299/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Mon, 8 Jun 2020 07:42:45 +0000 (09:42 +0200)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Mon, 8 Jun 2020 07:42:45 +0000 (09:42 +0200)
* The parent constructor was not called
* `get_class` does not allow null values in php7.2+

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
lib/private/EventDispatcher/GenericEventWrapper.php

index d1d136affc0d2f3119cb01bb6a4715634fc5f36f..dc3e7553f0c7670d4cdf4a03b830a345b525c4b8 100644 (file)
@@ -40,24 +40,26 @@ class GenericEventWrapper extends GenericEvent {
        private $eventName;
 
        public function __construct(ILogger $logger, string $eventName, ?GenericEvent $event) {
+               parent::__construct($eventName);
                $this->logger = $logger;
                $this->event = $event;
                $this->eventName = $eventName;
        }
 
        private function log() {
+               $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' => is_object($this->event) ? get_class($this->event) : 'null' ]
+                       [ 'name' => $this->eventName, 'class' => $class]
                );
        }
 
-       public function isPropagationStopped() {
+       public function isPropagationStopped(): bool {
                $this->log();
                return $this->event->isPropagationStopped();
        }
 
-       public function stopPropagation() {
+       public function stopPropagation(): void {
                $this->log();
                $this->event->stopPropagation();
        }