When running update.php, it would be nice if it automatically temporarily turned site maintenance on so that the schema doesn't break when users are visiting the site during an update.

Comments

robloach’s picture

Status: Active » Needs review
StatusFileSize
new910 bytes

There must be a better way around this.... Thoughts?

Anonymous’s picture

Makes sense to me, the code looks good; now, I just need to test it.

dries’s picture

Status: Needs review » Needs work

I think this is the correct way to do it. I recommend that we add a PHP comment. With some code comments, this pach is RTBC.

robloach’s picture

Status: Needs work » Needs review
StatusFileSize
new1.11 KB

Someone else may be a better writer then I, but here is the patch with some code comments.....

robloach’s picture

StatusFileSize
new1.1 KB

Avoiding the whitespace bug.

dries’s picture

Status: Needs review » Fixed

Looks great Rob. Committed to CVS HEAD. Thanks.

damien tournoud’s picture

Status: Fixed » Active

Was this even tested?

Looks to me that this code will never be called:

   batch_process($base_url . '/update.php?op=results', $base_url . '/update.php');
+
+  // Now that the update is done, we can disable site maintenance if
+  // it was previously turned off.
+  if ($site_offline == FALSE) {
+    variable_set('site_offline', FALSE);
+  }

because it is just after a batch_process() (which drupal_goto in the general case...).

Also I would like to see this behavior configurable. I'm pretty sure there are use cases (automatic staging etc.) in which you don't want this to happen automatically.

robloach’s picture

Status: Active » Needs review
StatusFileSize
new2.32 KB

Moved it to the update_finished function with a session variable keeping track of if the site was previously online. This look better? Also adds a checkbox in "admin/settings/site-maintenance" to allow the user to choose whether this happens or not (FALSE by default).

keith.smith’s picture

Status: Needs review » Needs work

A minor issue only, but:

     '#description' => t('Message to show visitors when the site is in offline mode.')
   );
 
+  $form['site_offline_during_update'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Turn site offline during update'),
+    '#default_value' => variable_get('site_offline_during_update', FALSE),
+    '#description' => t('When performing a site update, temporarily toggle site maintenance.')
+  );
+
   return system_settings_form($form);
 }

If we refer to "offline mode" in the previous description, the description in the new form field should use the same term rather than "site maintenance", IMO. That would make it something like "When performing a site update, temporarily toggle offline mode."

Also, I'm not certain about the use of the word "Turn" in the title; it strikes me as a use that will be hard to translate directly. Why not something like "Enable offline mode during update", or something similar.

sun’s picture

Category: feature » task
Status: Needs work » Needs review
StatusFileSize
new1.74 KB

As discussed on IRC, the original logic was sufficient. No extra setting required.

However, added some failsafe check to update_finished(), so that site maintenance is only disabled if everything went really well.

Also, cleaned-up the inline comments.

robloach’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, sun! It looks good.... Applies cleanly too.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

tnanek’s picture

Component: usability » ajax system

Not sure if this is the place I should be commenting on it, but right now, when the site is already in maintenance mode prior to going to update it, it incorrectly implies that the site was taken out of maintenance mode. I think the text on the page should be altered if the site was already in maintenance mode prior, but thats just my opinion.

rfay’s picture

Component: ajax system » update system

@Ninja Overlord, this is definitely *not* the place to comment on it. Please describe your issue completely and clearly in a new issue. Commenting on a closed issue just means being ignored (because if a tree falls in the forest and nobody hears it, did it really fall?)