Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrestaShop update debug regex not compatible with supplied defines_custom.inc.php #330

Open
TechhDan opened this issue Mar 15, 2023 · 0 comments

Comments

@TechhDan
Copy link

TechhDan commented Mar 15, 2023

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.

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 problem has been reported on two occasions.

PrestaShop/PrestaShop#30773
PrestaShop/PrestaShop#26400

Diagnosis

This repo provides PrestaShop a defines_custom.inc.php. A boolean casted getenv function is used to define the PS_MODE_DEV 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant