Symptom 1: Unable to toggle debug mode from the back-office. An error is thrown. Permissions are set correctly.
or
Symptom 2: The toggle switch shows debug is OFF but the top shows debug is ON.
Error: Could not find whether debug mode is enabled. Make sure that the correct permissions are set on the file /var/www/html/app/../config/defines.inc.php
This repo provides PrestaShop a defines_custom.inc.php. A boolean casted getenv function is used to define the _PS_MODEDEV constant. PrestaShop validates this file by using a regex which does not match this format. PrestaShop expects a true or false value in order for this regex to match.
This PrestaShop regex does not match (bool) getenv('PS_DEV_MODE')
# src/Adapter/Debug/DebugMode.php
private function updateDebugModeValueInCustomFile($value)
{
...
if (!preg_match('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', $cleanedFileContent)) {
....
}
Solution
Go into config/defines_custom.inc.php and replace (bool) getenv('PS_DEV_MODE') with true or false
Problem
Symptom 1: Unable to toggle debug mode from the back-office. An error is thrown. Permissions are set correctly. or Symptom 2: The toggle switch shows debug is OFF but the top shows debug is ON.
This problem has been reported on two occasions.
https://github.com/PrestaShop/PrestaShop/issues/30773 https://github.com/PrestaShop/PrestaShop/issues/26400
Diagnosis
This repo provides PrestaShop a defines_custom.inc.php. A boolean casted getenv function is used to define the _PS_MODEDEV constant. PrestaShop validates this file by using a regex which does not match this format. PrestaShop expects a
true
orfalse
value in order for this regex to match.This PrestaShop regex does not match
(bool) getenv('PS_DEV_MODE')
Solution
Go into
config/defines_custom.inc.php
and replace(bool) getenv('PS_DEV_MODE')
withtrue
orfalse