Răsfoiți Sursa

Enforce the handler is callable before calling it

Jordi Boggiano 13 ani în urmă
părinte
comite
30b48f1231
1 a modificat fișierele cu 6 adăugiri și 3 ștergeri
  1. 6 3
      src/Monolog/Handler/FingersCrossedHandler.php

+ 6 - 3
src/Monolog/Handler/FingersCrossedHandler.php

@@ -79,10 +79,13 @@ class FingersCrossedHandler extends AbstractHandler
                     $this->buffering = false;
                 }
                 if (!$this->handler instanceof HandlerInterface) {
+                    if (!is_callable($this->handler)) {
+                        throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object");
+                    }
                     $this->handler = call_user_func($this->handler, $record, $this);
-                }
-                if (!$this->handler instanceof HandlerInterface) {
-                    throw new \RuntimeException("The factory callback should return a HandlerInterface");
+                    if (!$this->handler instanceof HandlerInterface) {
+                        throw new \RuntimeException("The factory callable should return a HandlerInterface");
+                    }
                 }
                 $this->handler->handleBatch($this->buffer);
                 $this->buffer = array();