Skip to content

Commit

Permalink
Handle the situation when GRAV_ROOT or GRAV_WEBROOT are / (#3667)
Browse files Browse the repository at this point in the history
* Handle the situation when GRAV_ROOT or GARV_WEBROOT are `/`

* Update defines.php

Replaced `/` with `DS`

* Update Backups.php

Replaced `/` with `DS` in `backup` function
  • Loading branch information
thebodzio committed Apr 16, 2024
1 parent 04f9385 commit d184e25
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions system/defines.php
Expand Up @@ -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')) {
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Backup/Backups.php
Expand Up @@ -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)) {
Expand Down

0 comments on commit d184e25

Please sign in to comment.