瀏覽代碼

Enforce the handler is callable before calling it

Jordi Boggiano 13 年之前
父節點
當前提交
30b48f1231
共有 1 個文件被更改,包括 6 次插入3 次删除
  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();