Security update for Core, with self-updated composer
[yaffs-website] / vendor / psy / psysh / src / Psy / ConfigPaths.php
index 2295a911be49ad9a15c89fb34098beb4ff35d377..6672491992043db4a3be9957eb8d9f5a9b487402 100644 (file)
@@ -136,7 +136,22 @@ class ConfigPaths
     {
         $xdg = new Xdg();
 
-        return $xdg->getRuntimeDir(false) . '/psysh';
+        set_error_handler(array('Psy\Exception\ErrorException', 'throwException'));
+
+        try {
+            // XDG doesn't really work on Windows, sometimes complains about
+            // permissions, sometimes tries to remove non-empty directories.
+            // It's a bit flaky. So we'll give this a shot first...
+            $runtimeDir = $xdg->getRuntimeDir(false);
+        } catch (\Exception $e) {
+            // Well. That didn't work. Fall back to a boring old folder in the
+            // system temp dir.
+            $runtimeDir = sys_get_temp_dir();
+        }
+
+        restore_error_handler();
+
+        return strtr($runtimeDir, '\\', '/') . '/psysh';
     }
 
     private static function getDirNames(array $baseDirs)