From 1b907c7faa33d2f589466a228f2116c0aa00731a Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Thu, 23 Apr 2026 17:58:45 +0530 Subject: [PATCH] Update the function and Co-authored-by: Name sumit201@webkul.in --- .../admin/AdminPerformanceController.php | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/controllers/admin/AdminPerformanceController.php b/controllers/admin/AdminPerformanceController.php index 10e42f33f..2e2af3a27 100644 --- a/controllers/admin/AdminPerformanceController.php +++ b/controllers/admin/AdminPerformanceController.php @@ -922,28 +922,20 @@ class AdminPerformanceControllerCore extends AdminController public function updateDebugMode($value) { $filename = _PS_ROOT_DIR_ . '/config/defines.inc.php'; - - if (!is_readable($filename)) { - return false; + if (is_readable($filename)) { + $cleanedFileContent = php_strip_whitespace($filename); + if (preg_match('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', $cleanedFileContent)) { + $fileContent = Tools::file_get_contents($filename); + $fileContent = preg_replace('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', 'define(\'_PS_MODE_DEV_\', ' . $value . ');', $fileContent); + if (@file_put_contents($filename, $fileContent)) { + if (function_exists('opcache_invalidate')) { + @opcache_invalidate($filename); + } + return true; + } + } } - - $cleanedFileContent = php_strip_whitespace($filename); - $fileContent = Tools::file_get_contents($filename); - - if (!preg_match('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', $cleanedFileContent)) { - return false; - } - - $fileContent = preg_replace('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', 'define(\'_PS_MODE_DEV_\', ' . $value . ');', $fileContent); - if (!@file_put_contents($filename, $fileContent)) { - return false; - } - - if (function_exists('opcache_invalidate')) { - @opcache_invalidate($filename); - } - - return true; + return false; } public function displayAjaxTestServer()