Question

I understand there are very many stackoverflow questions on this very topic.

How can get my site out of maintenance mode? for example.

However I've never seen one that explains how to turn off maintenance mode using only a database query. I run a complex site that does not allow you to login directly using /user since it's using a special sso. So there are times when I do not have access to the admin area and I do not have access to the user login either. I don't always have ssh access to run drush, but I do usually have direct access to the mysql database.

I did find an entry in the config table that seems related.

The name is system.maintenance and the data is

a:3:{s:7:"message";s:93:"@site is currently under maintenance. We should be back shortly. Thank you for your patience.";s:8:"langcode";s:2:"en";s:5:"_core";a:1:{s:19:"default_config_hash";s:43:"Z5MXifrF77GEAgx0GQ6iWT8wStjFuY8BD9OruofWTJ8";}}

I see where it shows the message, langcode and hash settings but I do not see where it defines whether it's on or off.

Is there a location in the database that would allow me to turn maintenance mode on and off directly?

Was it helpful?

Solution

It's never the best idea to manipulate the database directly (for the usual reasons), but if you're out of other options, it's not that unsafe:

UPDATE key_value 
SET value = '<value>' 
WHERE collection = 'state' 
AND name = 'system.maintenance_mode'

Where <value> is replaced with a serialised PHP string representing the integer value 1 for enabled, or 0 for disabled, e.g.

$value = serialize(1);

You'll probably want to invoke a cache rebuild after manually updating the variable, it's probably cached somewhere.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top