diff --git a/CHANGELOG.md b/CHANGELOG.md index cf395779b4..7758825c4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -123,6 +123,7 @@ 1. [](#improved) * Removed outdated `xcache` setting [#3615](https://github.com/getgrav/grav/pull/3615) * Updated `robots.txt` [#3625](https://github.com/getgrav/grav/pull/3625) + * Handle the situation when GRAV_ROOT or GRAV_WEBROOT are `/` [#3625](https://github.com/getgrav/grav/pull/3667) 1. [](#bugfix) * Fixed `force_ssl` redirect in case of undefined hostname [#3702](https://github.com/getgrav/grav/pull/3702) * Fixed an issue with duplicate identical page paths diff --git a/system/defines.php b/system/defines.php index 2bb2fd858e..10388666f3 100644 --- a/system/defines.php +++ b/system/defines.php @@ -26,12 +26,12 @@ // Absolute path to Grav root. This is where Grav is installed into. if (!defined('GRAV_ROOT')) { $path = rtrim(str_replace(DIRECTORY_SEPARATOR, DS, getenv('GRAV_ROOT') ?: getcwd()), DS); - define('GRAV_ROOT', $path); + define('GRAV_ROOT', $path ?: DS); } // Absolute path to Grav webroot. This is the path where your site is located in. if (!defined('GRAV_WEBROOT')) { $path = rtrim(getenv('GRAV_WEBROOT') ?: GRAV_ROOT, DS); - define('GRAV_WEBROOT', $path); + define('GRAV_WEBROOT', $path ?: DS); } // Relative path to user folder. This path needs to be located under GRAV_WEBROOT. if (!defined('GRAV_USER_PATH')) { diff --git a/system/src/Grav/Common/Backup/Backups.php b/system/src/Grav/Common/Backup/Backups.php index 5114634643..dd2cf379c9 100644 --- a/system/src/Grav/Common/Backup/Backups.php +++ b/system/src/Grav/Common/Backup/Backups.php @@ -218,7 +218,7 @@ public static function backup($id = 0, callable $status = null) if ($locator->isStream($backup_root)) { $backup_root = $locator->findResource($backup_root); } else { - $backup_root = rtrim(GRAV_ROOT . $backup_root, '/'); + $backup_root = rtrim(GRAV_ROOT . $backup_root, DS) ?: DS; } if (!$backup_root || !file_exists($backup_root)) {