In the new releases of the versions 1.7.x.x. I found an issue related with the use of __DIR__ and __FILE__ constants to build paths and persistence environments. I will try to describe the situation:
Prestashop Installation Directory: /home/user/prestashop/
Persistence Directory: /persitance/prestashop/
Directories to Persist: /home/user/prestashop/modules, /home/user/prestashop/config, /home/user/prestashop/uploads, /home/user/prestashop/downloads, /home/user/prestashop/themes, /home/user/prestashop/img, /home/user/prestashop/app/config and /home/user/prestashop/app/logs.
I created symlinks from /home/user/prestashop/DIRECTORY to /persitance/prestashop/DIRECTORY for every directory I wanted to persist. The purpose of this is being able to persist the DATA of PrestaShop on a Volume with benefits on containers environments.
Problem:
On previous versions (1.6.x.x) I just needed to edit the file `config/defines.inc.php`:
/* Directories */
if (!defined('_PS_ROOT_DIR_')) {
define('_PS_ROOT_DIR_', realpath($currentDir.'/..'));
}
with:
/* Directories */
if (!defined('_PS_ROOT_DIR_')) {
define('_PS_ROOT_DIR_', '/home/user/prestashop');
}
All the paths were built using that constant and everything worked fine.So... What's the problem now?
There are dozens of php files under some of the persisted directories that use __DIR__ and __FILE__ php constants to build relative paths.
When using those constants (e.g. file: modules/welcome/welcome-api.php line 27):
require_once(__DIR__.'/../../init.php');
The path is resolved to /persisted/prestashop/init.php since __DIR__ is resolved using the path to the persisted directory. However, the file referenced is NOT persisted and it's actually is at /home/user/prestashop/init.php.
The situation described before creates dozens of Server Internal Errors.
Is there anyway to configure the PrestaShop 1.7.x.x to indicate to ALL the files to build the paths using '_PS_ROOT_DIR_' as we could did it before?