Define GRAV_ROOT constant outside Grav Core


#1

Hello,

I would like to know is if there is any possibility of being able to define GRAV_ROOT constant before the declaration of it ( /system/defines.php :: 20 )
if (!defined('GRAV_ROOT')) {
define('GRAV_ROOT', str_replace(DIRECTORY_SEPARATOR, DS, getcwd()));
}

The problem is that I am working with sessions and I have noticed that grav uses current working directory to create the name of the session ( /system/src/Grav/Common/Service/SessionServiceProvider.php :: 71 )
$session_name = $inflector->hyphenize($config->get('system.session.name', 'grav_site')) . '-' . substr(md5(**getcwd()**), 0, 7);

When I deploy the new code (with ansible), current directory of the project changes from
/var/www/project/releases/20183010120000Z/
to
/var/www/project/releases/20183010130000Z/

Ansible automatically creates a symlink from
/var/ww/project/current/
to the latest release when a deploy is made (all deployment software work like this)

due to the root path changes, session name also changes (it depends on getcwd()), therefore user session is lost (old session name is not used anymore).

If GRAV_ROOT can’t be predefined, would it be possible to create a feature on your side for not using getcwd() in the session name?

Regards,
xavi