diff --git a/system/defines.php b/system/defines.php index 51e2bc1f2..bf86ec12d 100644 --- a/system/defines.php +++ b/system/defines.php @@ -57,24 +57,24 @@ if (!defined('GRAV_BACKUP_PATH')) { } unset($path); -define('USER_PATH', GRAV_USER_PATH . DS); -define('CACHE_PATH', GRAV_CACHE_PATH . DS); -define('ROOT_DIR', GRAV_ROOT . DS); -define('USER_DIR', GRAV_WEBROOT . '/' . USER_PATH); -define('CACHE_DIR', (!str_starts_with(CACHE_PATH, '/') ? ROOT_DIR : '') . CACHE_PATH); +define('USER_DIR', GRAV_WEBROOT . '/' . USER_PATH . '/'); +define('CACHE_DIR', (!str_starts_with(GRAV_CACHE_PATH, '/') ? GRAV_ROOT . '/' : '') . GRAV_CACHE_PATH . '/'); // DEPRECATED: Do not use! +define('CACHE_PATH', GRAV_CACHE_PATH . DS); +define('USER_PATH', GRAV_USER_PATH . DS); +define('ROOT_DIR', GRAV_ROOT . DS); define('ASSETS_DIR', GRAV_WEBROOT . '/assets/'); define('IMAGES_DIR', GRAV_WEBROOT . '/images/'); -define('ACCOUNTS_DIR', USER_DIR .'accounts/'); -define('PAGES_DIR', USER_DIR .'pages/'); -define('DATA_DIR', USER_DIR .'data/'); -define('PLUGINS_DIR', USER_DIR .'plugins/'); -define('THEMES_DIR', USER_DIR .'themes/'); -define('SYSTEM_DIR', (!str_starts_with(GRAV_SYSTEM_PATH, '/') ? ROOT_DIR : '') . GRAV_SYSTEM_PATH); -define('LIB_DIR', SYSTEM_DIR .'src/'); -define('VENDOR_DIR', ROOT_DIR .'vendor/'); -define('LOG_DIR', (!str_starts_with(GRAV_LOG_PATH, '/') ? ROOT_DIR : '') . GRAV_LOG_PATH . DS); +define('ACCOUNTS_DIR', USER_DIR . 'accounts/'); +define('PAGES_DIR', USER_DIR . 'pages/'); +define('DATA_DIR', USER_DIR . 'data/'); +define('PLUGINS_DIR', USER_DIR . 'plugins/'); +define('THEMES_DIR', USER_DIR . 'themes/'); +define('SYSTEM_DIR', (!str_starts_with(GRAV_SYSTEM_PATH, '/') ? GRAV_ROOT . '/' : '') . GRAV_SYSTEM_PATH . '/'); +define('LIB_DIR', SYSTEM_DIR . 'src/'); +define('VENDOR_DIR', GRAV_ROOT . '/vendor/'); +define('LOG_DIR', (!str_starts_with(GRAV_LOG_PATH, '/') ? GRAV_ROOT . '/' : '') . GRAV_LOG_PATH . '/'); // END DEPRECATED // Some extensions diff --git a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php index a2dad4faa..902a7c509 100644 --- a/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php +++ b/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php @@ -90,7 +90,7 @@ trait AssetUtilsTrait } $relative_dir = dirname($relative_path); - $link = ROOT_DIR . $relative_path; + $link = GRAV_ROOT . '/' . $relative_path; } // TODO: looks like this is not being used. diff --git a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php index cb8de18ae..15dc00e3d 100644 --- a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php +++ b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php @@ -252,7 +252,7 @@ trait TestingAssetsTrait */ public function addDir($directory, $pattern = self::DEFAULT_REGEX) { - $root_dir = rtrim(ROOT_DIR, '/'); + $root_dir = GRAV_ROOT; // Check if $directory is a stream. if (strpos($directory, '://')) { diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php index 1b15e5de8..222aa0ada 100644 --- a/system/src/Grav/Common/GPM/GPM.php +++ b/system/src/Grav/Common/GPM/GPM.php @@ -527,7 +527,7 @@ class GPM extends Iterator $plugins = $this->getRepositoryPlugins(); if (null === $themes || null === $plugins) { - if (!is_writable(ROOT_DIR . '/cache/gpm')) { + if (!is_writable(GRAV_ROOT . '/cache/gpm')) { throw new RuntimeException('The cache/gpm folder is not writable. Please check the folder permissions.'); } diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 5c92cba9a..a0356134c 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -2095,7 +2095,7 @@ class Page implements PageInterface */ public function filePathClean() { - return str_replace(ROOT_DIR, '', $this->filePath()); + return str_replace(GRAV_ROOT . DS, '', $this->filePath()); } /** diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index d4f710be3..5e0dcf751 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -211,7 +211,7 @@ class Twig 'assets' => $this->grav['assets'], 'taxonomy' => $this->grav['taxonomy'], 'browser' => $this->grav['browser'], - 'base_dir' => rtrim(ROOT_DIR, '/'), + 'base_dir' => GRAV_ROOT, 'home_url' => $pages->homeUrl($active_language), 'base_url' => $pages->baseUrl($active_language), 'base_url_absolute' => $pages->baseUrl($active_language, true), diff --git a/system/src/Grav/Console/Cli/InstallCommand.php b/system/src/Grav/Console/Cli/InstallCommand.php index 08bc7144e..22258beb3 100644 --- a/system/src/Grav/Console/Cli/InstallCommand.php +++ b/system/src/Grav/Console/Cli/InstallCommand.php @@ -73,11 +73,11 @@ class InstallCommand extends GravCommand $io = $this->getIO(); $dependencies_file = '.dependencies'; - $this->destination = $input->getArgument('destination') ?: GRAV_ROOT; + $this->destination = $input->getArgument('destination') ?: GRAV_WEBROOT; // fix trailing slash $this->destination = rtrim($this->destination, DS) . DS; - $this->user_path = $this->destination . USER_PATH; + $this->user_path = $this->destination . GRAV_USER_PATH . DS; if ($local_config_file = $this->loadLocalConfig()) { $io->writeln('Read local config from ' . $local_config_file . ''); } diff --git a/tests/phpstan/plugins-bootstrap.php b/tests/phpstan/plugins-bootstrap.php index 1beaaa69f..c28f2ab8a 100644 --- a/tests/phpstan/plugins-bootstrap.php +++ b/tests/phpstan/plugins-bootstrap.php @@ -62,7 +62,7 @@ foreach ($iterator as $directory) { define('GANTRY_DEBUGGER', true); define('GANTRY5_DEBUG', true); define('GANTRY5_PLATFORM', 'grav'); -define('GANTRY5_ROOT', rtrim(ROOT_DIR, '/')); +define('GANTRY5_ROOT', GRAV_ROOT); define('GANTRY5_VERSION', '@version@'); define('GANTRY5_VERSION_DATE', '@versiondate@'); define('GANTRYADMIN_PATH', '');