Ver código fonte

Auto-close streams when reset() is called, fixes #1862

Jordi Boggiano 1 ano atrás
pai
commit
0c7366171f
1 arquivos alterados com 14 adições e 0 exclusões
  1. 14 0
      src/Monolog/Handler/StreamHandler.php

+ 14 - 0
src/Monolog/Handler/StreamHandler.php

@@ -79,6 +79,20 @@ class StreamHandler extends AbstractProcessingHandler
         $this->useLocking = $useLocking;
     }
 
+    /**
+     * @inheritDoc
+     */
+    public function reset(): void
+    {
+        parent::reset();
+
+        // auto-close on reset to make sure we periodically close the file in long running processes
+        // as long as they correctly call reset() between jobs
+        if ($this->url !== null && $this->url !== 'php://memory') {
+            $this->close();
+        }
+    }
+
     /**
      * @inheritDoc
      */