1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 16:36:47 +02:00

Add server metadata in writable paths errors

This commit is contained in:
Alexander Skvortsov
2021-12-12 14:38:08 -05:00
parent 02f351001c
commit 3da7d7d221

View File

@@ -28,8 +28,33 @@ class WritablePaths implements PrerequisiteInterface
public function problems(): Collection
{
return $this->getMissingPaths()
$problems = $this->getMissingPaths()
->concat($this->getNonWritablePaths());
if (!$problems->isEmpty()) {
return $problems->prepend($this->getServerInfo());
}
return $problems;
}
private function getServerInfo(): array
{
return [
'title' => 'Server Metadata',
'detail' => implode('<br />', [
'The following information might be useful for troubleshooting the errors below.',
'Current User:' . get_current_user(),
'Current File Permissions:',
$this->paths->map(function ($path) {
return " - $path: " . substr(sprintf('%o', fileperms($path)), -4);
})->implode('<br />'),
'Current File Ownership:',
$this->paths->map(function ($path) {
return " - $path: " . posix_getpwuid(fileowner($path))['name'] .':'.posix_getgrgid(filegroup($path))['name'];
})->implode('<br />'),
]),
];
}
private function getMissingPaths(): Collection