From 506dd6028cb75c48607fe8a3b3eb0f1c6e3882a9 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 3 Aug 2018 07:25:41 +0200 Subject: [PATCH] Closes #3235 by backporting 32cbcdf37b8aead005883e51dbaf9ac7521c6af8 --- src/Util/Printer.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Util/Printer.php b/src/Util/Printer.php index d0e8a70fca1..d5c6c18df39 100644 --- a/src/Util/Printer.php +++ b/src/Util/Printer.php @@ -54,7 +54,7 @@ public function __construct($out = null) $this->out = \fsockopen($out[0], $out[1]); } else { if (\strpos($out, 'php://') === false && !\is_dir(\dirname($out))) { - \mkdir(\dirname($out), 0777, true); + $this->createDirectory(\dirname($out)); } $this->out = \fopen($out, 'wt'); @@ -143,4 +143,9 @@ public function setAutoFlush($autoFlush) throw InvalidArgumentHelper::factory(1, 'boolean'); } } + + private function createDirectory(string $directory): bool + { + return !(!\is_dir($directory) && !@\mkdir($directory, 0777, true) && !\is_dir($directory)); + } }