Support » Fixing WordPress » Maintenance Mode Built-In to WordPress?

  • I’ve searched high and low on this site for any information about the built-in maintenance mode in WordPress. I know there is a plugin called maintenance mode, but I’m trying to get more information about what is already standard in WordPress.

    In the wp-settings.php file, I can see code that looks like it should automatically say your site is in maintenance mode when an upgrade is running. However, both times I’ve upgraded WordPress and checked the home page of the site, it just hangs until the upgrade is completed.

    I do know PHP pretty well, but I’m not familiar with exactly what all happens behind the scenes in a WordPress upgrade to know what the likely values of all these variables are during the actual upgrade process.

    I would think WP_INSTALLING would only be defined during the initial install not during an upgrade. I don’t know what process would place a file called ‘.maintenance’ in the root directory, but it seems reasonable that the upgrade process would do that. Then according to the comments, the ( time() – $upgrading stuff ) logic is there to keep the upgrade from dying after the normal php timeout amount of time. Now that section issues a die() which forces it drop out of the code before that HTML page saying the site is undergoing maintenance ever gets displayed.

    Why wouldn’t we actually want to go ahead and display that every time wp-settings.php is called during the upgrade to inform users of the maintenance? It seems according to this code that message would only get displayed if the upgrade takes more than 10 minutes.

    if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) {
    	include(ABSPATH . '.maintenance');
    	// If the $upgrading timestamp is older than 10 minutes, don't die.
    	if ( ( time() - $upgrading ) < 600 ) {
    		if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
    			require_once( WP_CONTENT_DIR . '/maintenance.php' );
    		$protocol = $_SERVER["SERVER_PROTOCOL"];
    		if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
    			$protocol = 'HTTP/1.0';
    		header( "$protocol 503 Service Unavailable", true, 503 );
    		header( 'Content-Type: text/html; charset=utf-8' );
    		header( 'Retry-After: 600' );
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    	<h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1>
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Maintenance Mode Built-In to WordPress?’ is closed to new replies.