Page 1 of 2

Automatic Maintenance

Posted: Mon Jun 01, 2015 12:15 am
by swatpc
installing modules OCMOD the store goes into maintenance

Re: Automatic Maintenance

Posted: Mon Jun 01, 2015 1:46 am
by chulcha

Re: Automatic Maintenance

Posted: Mon Jun 01, 2015 3:34 am
by aljawaid
http://forum.opencart.com/viewtopic.php ... 48#p563468

Follow that post for the solution. It seems like a bug - I think. But the fix by viethemes seems to work. :)

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 4:13 pm
by fido-x
This is not a bug, merely an inconvenience. Your site will automatically be switched to maintenance mode when you refresh your modification cache. This gives you (as admin) the chance to check that the modification is working before allowing customers to view your store.

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 4:20 pm
by aljawaid
fido-x wrote:This is not a bug, merely an inconvenience. Your site will automatically be switched to maintenance mode when you refresh your modification cache. This gives you (as admin) the chance to check that the modification is working before allowing customers to view your store.
I see your point and it makes sense to do it that way too, but in this case, with this version, it seems to be "staying" in maintenance mode after refreshing.

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 4:29 pm
by fido-x
You have to turn maintenance mode off yourself. It isn't done automatically.

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 4:35 pm
by OSWorX
fido-x wrote:You have to turn maintenance mode off yourself. It isn't done automatically.
I made a while ago a pull request at GitHub to check the maintenance mode before doing the modification.
During modification switch maintenance mode to OFF and restore afterwards to the state it was before.

Seems that got lost ...
And it seems useless to do PRs at GH, just wasting my time.

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 4:55 pm
by fido-x
This is in admin/controller/extension/modification.php (lines 62 to 68):

Code: Select all

$org_maintenance = $this->config->get('config_maintenance');
if (!$this->config->get('config_maintenance')) {
	$this->load->model('setting/setting');

	$this->model_setting_setting->editSettingValue('config', 'config_maintenance', true);
}
This should store the maintenance mode setting prior to refreshing the modification cache.

And, further down (lines 418 to 420):

Code: Select all

if ($org_maintenance != $this->config->get('config_maintenance')) {
	$this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}
This should reset maintenance mode to what it was before refreshing the modification cache. Obviously not working, so I suppose this is a bug.

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 6:00 pm
by OSWorX
fido-x wrote:This is in admin/controller/extension/modification.php (lines 62 to 68):

Code: Select all

$org_maintenance = $this->config->get('config_maintenance');
if (!$this->config->get('config_maintenance')) {
	$this->load->model('setting/setting');

	$this->model_setting_setting->editSettingValue('config', 'config_maintenance', true);
}
This should store the maintenance mode setting prior to refreshing the modification cache.

And, further down (lines 418 to 420):

Code: Select all

if ($org_maintenance != $this->config->get('config_maintenance')) {
	$this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}
This should reset maintenance mode to what it was before refreshing the modification cache. Obviously not working, so I suppose this is a bug.
Yes, this was my PR.
And yes, should be reworked, considering this as a bug - sorry.

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 6:28 pm
by fido-x
Just change this bit from:

Code: Select all

if ($org_maintenance != $this->config->get('config_maintenance')) {
 $this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}
to:

Code: Select all

if (!$org_maintenance) {
 $this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 11:10 pm
by aljawaid
fido-x wrote:Just change this bit from:

Code: Select all

if ($org_maintenance != $this->config->get('config_maintenance')) {
 $this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}
to:

Code: Select all

if (!$org_maintenance) {
 $this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}
A bit confusing now what I should be using. You say the viethemes vqmod is wrong but it works for me. But then today, the site made itself offline again. Not sure if it has something to do with cookies etc.

So this code above... does anyone have a vqmod for it? or which file should it be done in? The same code is mentioned twice on this page so I'm not sure which one to follow now.

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 11:22 pm
by fido-x
When you click the "Refresh" button to refresh your modification cache, your site is put into maintenance mode so that while the modification cache is being rebuilt, any visitors to your site will see it in maintenance mode. The problem is, that it is not being taken out of maintenance mode when finished.

To fix, replace this (lines 418 to 420) in admin/controller/extension/modification.php

Code: Select all

if ($org_maintenance != $this->config->get('config_maintenance')) {
 $this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}
with:

Code: Select all

if (!$org_maintenance) {
 $this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}
This will need to be hard-coded as the modification.php file can not be modified while it is in use.

The code provided by viethemes only ensures that maintenance mode stays turned on.

Re: Automatic Maintenance

Posted: Thu Jun 04, 2015 11:29 pm
by OSWorX
fido-x is correct - thanks for the update (made that PR very fast, too fast).
Should now someone make a new PR ..

Re: Automatic Maintenance

Posted: Fri Jun 05, 2015 12:01 am
by OSWorX

Re: Automatic Maintenance

Posted: Fri Jun 05, 2015 5:52 am
by aljawaid
fido-x wrote: To fix, replace this (lines 418 to 420) in admin/controller/extension/modification.php

Code: Select all

if ($org_maintenance != $this->config->get('config_maintenance')) {
 $this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}
with:

Code: Select all

if (!$org_maintenance) {
 $this->model_setting_setting->editSettingValue('config', 'config_maintenance', false);
}
This will need to be hard-coded as the modification.php file can not be modified while it is in use.

The code provided by viethemes only ensures that maintenance mode stays turned on.
Thank you for this, I have done it and will monitor. Thanks for the explanation too, it helps more. O0

Re: Automatic Maintenance

Posted: Wed Jun 10, 2015 6:45 pm
by skimottaret
I am having the same issue, is this a bug? I have installed VQMod and am testing a new shop using 2.0.3.1 and Journal theme 2.5.2

Surely I don't have to add special code patches so my shop can be viewed, or do I?

www.insideoutskiing.com/sales2

Re: Automatic Maintenance

Posted: Thu Jun 11, 2015 11:47 pm
by fido-x
skimottaret wrote:I am having the same issue, is this a bug? I have installed VQMod and am testing a new shop using 2.0.3.1 and Journal theme 2.5.2

Surely I don't have to add special code patches so my shop can be viewed, or do I?

http://www.insideoutskiing.com/sales2
You have a choice. You can apply the fix as stated above. You can get an update from GitHub. Or, just remember that refreshing your modification cache will put your site into maintenance mode while rebuilding the modification cache and "forget" to take it out of maintenance mode. Which means you will have to go to your system settings and take it out of maintenance mode yourself. The choice is yours.

Re: Automatic Maintenance

Posted: Fri Jun 12, 2015 12:34 am
by skimottaret
Thank you, looking closer I didn't appreciate that there was a selectable system setting for taking out of maintenance mode.

Re: Automatic Maintenance

Posted: Sat Jul 11, 2015 7:44 am
by sunsys
fido-x wrote:You have a choice. You can apply the fix as stated above. You can get an update from GitHub. Or, just remember that refreshing your modification cache will put your site into maintenance mode while rebuilding the modification cache and "forget" to take it out of maintenance mode. Which means you will have to go to your system settings and take it out of maintenance mode yourself. The choice is yours.
Yes fido-x you are right in this aspect but there is also one more problem and that is of mobile site, with one extension I have solved the maintenance issue for desktop version but the same when viewed on the mobile shows as the site in maintenance mode so what can be done about that ?

Re: Automatic Maintenance

Posted: Sat Jul 11, 2015 2:55 pm
by fido-x
Could be related to the caching on your mobile device. Suggest clearing the cache in your mobile device's browser.