|
|
@@ -35,7 +35,27 @@ class DocumentStorageService
|
|
|
|
|
|
if (!is_dir($dir)) {
|
|
|
if (!@mkdir($dir, 0775, true) && !is_dir($dir)) {
|
|
|
- throw new \RuntimeException('Failed to create documents directory');
|
|
|
+ $lastError = error_get_last();
|
|
|
+ $root = rtrim($this->rootDir, '/');
|
|
|
+ $rootParent = dirname($root);
|
|
|
+
|
|
|
+ $debug = [
|
|
|
+ 'root_dir' => $root,
|
|
|
+ 'root_dir_exists' => is_dir($root),
|
|
|
+ 'root_dir_writable' => is_writable($root),
|
|
|
+ 'root_parent' => $rootParent,
|
|
|
+ 'root_parent_exists' => is_dir($rootParent),
|
|
|
+ 'root_parent_writable' => is_writable($rootParent),
|
|
|
+ 'target_dir' => $dir,
|
|
|
+ 'target_parent' => dirname($dir),
|
|
|
+ 'target_parent_exists' => is_dir(dirname($dir)),
|
|
|
+ 'target_parent_writable' => is_writable(dirname($dir)),
|
|
|
+ 'php_user' => get_current_user(),
|
|
|
+ 'euid' => function_exists('posix_geteuid') ? posix_geteuid() : null,
|
|
|
+ 'last_error' => $lastError,
|
|
|
+ ];
|
|
|
+
|
|
|
+ throw new \RuntimeException('Failed to create documents directory: ' . json_encode($debug, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -64,7 +84,14 @@ class DocumentStorageService
|
|
|
|
|
|
$bytes = @file_put_contents($path, $content, LOCK_EX);
|
|
|
if ($bytes === false) {
|
|
|
- throw new \RuntimeException('Failed to write file');
|
|
|
+ $lastError = error_get_last();
|
|
|
+ $debug = [
|
|
|
+ 'path' => $path,
|
|
|
+ 'dir_exists' => is_dir($dir),
|
|
|
+ 'dir_writable' => is_writable($dir),
|
|
|
+ 'last_error' => $lastError,
|
|
|
+ ];
|
|
|
+ throw new \RuntimeException('Failed to write file: ' . json_encode($debug, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
|
|
}
|
|
|
|
|
|
return $path;
|