Browse Source

Avoid warnings in case cache dir is explicitly directed to /dev/null, fixes #5468

Jordi Boggiano 8 years ago
parent
commit
fd6455218e
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/Composer/Cache.php

+ 5 - 0
src/Composer/Cache.php

@@ -44,6 +44,11 @@ class Cache
         $this->whitelist = $whitelist;
         $this->filesystem = $filesystem ?: new Filesystem();
 
+        if (preg_match('{(^|[\\\\/])(\$null|NUL|/dev/null)([\\\\/]|$)}', $cacheDir)) {
+            $this->enabled = false;
+            return;
+        }
+
         if (
             (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
             || !is_writable($this->root)