From a7782040d419efa9a63a5960d12a04d459d1a703 Mon Sep 17 00:00:00 2001 From: Markus Hansmair Date: Tue, 6 Apr 2021 20:50:29 +0200 Subject: [PATCH 1/2] adapted to configurable paths see https://github.com/getgrav/grav/issues/3297 --- classes/Problems/EssentialFolders.php | 44 ++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/classes/Problems/EssentialFolders.php b/classes/Problems/EssentialFolders.php index 7dae1de..a3e4e64 100644 --- a/classes/Problems/EssentialFolders.php +++ b/classes/Problems/EssentialFolders.php @@ -19,35 +19,37 @@ public function __construct() public function process() { $essential_folders = [ - 'backup' => true, - 'cache' => true, - 'logs' => true, - 'images' => true, - 'assets' => true, - 'system' => false, - 'user/data' => true, - 'user/pages' => false, - 'user/config' => false, - 'user/plugins/error' => false, - 'user/plugins' => false, - 'user/themes' => false, - 'vendor' => false, - 'tmp' => true, + (str_starts_with(GRAV_BACKUP_PATH, '/') ? '' : ROOT_DIR) . GRAV_BACKUP_PATH => true, + (str_starts_with(GRAV_CACHE_PATH, '/') ? '' : ROOT_DIR) . GRAV_CACHE_PATH => true, + (str_starts_with(GRAV_LOG_PATH, '/') ? '' : ROOT_DIR) . GRAV_LOG_PATH => true, + GRAV_WEBROOT . '/images' => true, + GRAV_WEBROOT . '/assets' => true, + (str_starts_with(GRAV_SYSTEM_PATH, '/') ? '' : ROOT_DIR) . GRAV_SYSTEM_PATH => false, + USER_DIR . 'data' => true, + USER_DIR . 'pages' => false, + USER_DIR . 'config' => false, + USER_DIR . 'plugins/error' => false, + USER_DIR . 'plugins' => false, + USER_DIR . 'themes' => false, + ROOT_DIR . 'vendor' => false, + (str_starts_with(GRAV_TMP_PATH, '/') ? '' : ROOT_DIR) . GRAV_TMP_PATH => false, ]; // Check for essential files & perms $file_errors = []; $file_success = []; - foreach ($essential_folders as $file => $check_writable) { - $file_path = ROOT_DIR . $file; - + foreach ($essential_folders as $file_path => $check_writable) { if (!file_exists($file_path)) { $file_errors[$file_path] = 'does not exist'; - } elseif ($check_writable && !is_writable($file_path)) { - $file_errors[$file_path] = 'exists but is not writeable'; + } elseif (!$check_writable) { + $file_success[$file_path] = 'exists'; } else { - $file_success[$file_path] = 'exists and is writable'; + if (is_writable($file_path)) { + $file_success[$file_path] = 'exists and is writable'; + } else { + $file_errors[$file_path] = 'exists but is not writeable'; + } } } @@ -63,4 +65,4 @@ public function process() return $this; } -} \ No newline at end of file +} From d9bef71404785cfaa0d31a7dc14c14fa4f92da71 Mon Sep 17 00:00:00 2001 From: Markus Hansmair Date: Fri, 9 Apr 2021 11:12:18 +0200 Subject: [PATCH 2/2] fixed check_writable flag for TMP path --- classes/Problems/EssentialFolders.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Problems/EssentialFolders.php b/classes/Problems/EssentialFolders.php index a3e4e64..48c84fc 100644 --- a/classes/Problems/EssentialFolders.php +++ b/classes/Problems/EssentialFolders.php @@ -32,7 +32,7 @@ public function process() USER_DIR . 'plugins' => false, USER_DIR . 'themes' => false, ROOT_DIR . 'vendor' => false, - (str_starts_with(GRAV_TMP_PATH, '/') ? '' : ROOT_DIR) . GRAV_TMP_PATH => false, + (str_starts_with(GRAV_TMP_PATH, '/') ? '' : ROOT_DIR) . GRAV_TMP_PATH => true, ]; // Check for essential files & perms