Elxis CMS Forum

Support => General => Topic started by: datahell on September 21, 2021, 22:46:31

Title: Saving configuration problem solved
Post by: datahell on September 21, 2021, 22:46:31
A strange problem occurred in some sites solved to day. When you try to save general configuration in Elxis administration area the settings were not saved. Or seems so. If you let some time pass (10-15 seconds) and then refresh the page you will see that finally have been saved. However most users think they are not saved and keep pressing the save button repetitively. This drives the user crazy. Finally the source of the problem was detected. This problem occurred on sites with opcache enabled in PHP. The solution to this problem is to clear the opcache after saving general configuration so Elxis displays directly the saved values after save and you dont have to wait 10 seconds in order to see them. This fix will be available on the next Elxis release. To fix it in your current installation do this (instructions for Elxis 5.2):

Open file components/com_cpanel/controllers/main.php
Scroll down to line 629:
if (!$ok) {
   $msg = $eFiles->getError();
   $elxis->redirect($url, $msg, true);
} else {
   $elxis->redirect($url, $eLang->get('SETS_SAVED_SUCC'));
}

And change it to this:
if (!$ok) {
   $msg = $eFiles->getError();
   $elxis->redirect($url, $msg, true);
} else {
   if (function_exists('opcache_get_status')) {//solve problem with config vars not immediately updated due to opcache
      $opc = opcache_get_status();
      if (is_array($opc)) {
         if ($opc['opcache_enabled'] == 1) { opcache_reset(); }
      }
   }
   $elxis->redirect($url, $eLang->get('SETS_SAVED_SUCC'));
}

Save the file and the problem is gone!