New maintenance and error features

Featured Image

New Magento 1.4 brings changes in how errors are displayed along with an easy way to put your favorite store into maintenance mode.

If you check index.php file of new Magento 1.4, you’ll notice one interesting thingy, it checks for existence of “maintenance.flag” file in store root, if it’s found your store is put into maintenance mode. Service Temporarily Unavailable page is displayed with Please try again later message. Remember that administration can’t be accessed in maintenance mode along with the store.

Developers probably noticed that errors also are no longer displayed like before, as mentioned on Magento blog:
Since version 1.4.0.0 for security reasons the trace in the Magento error report page is disabled by default. The “Error log number” does not give any information about the error. To enable the trace copy the errors/local.xml.sample to errors/local.xml and follow the instructions described in that file.

By default, error logs are placed in /var/report, named by mentioned log number. local.xml file is well commented, so open it and check possible configuration options. I really like emailing of error reports to specified email address.

If you want to change default maintenance look, you can change myskin value in /errors/local.xml file and create new /errors/myskin folder based on /errors/default. It functions the similar way as themes, if the phtml file isn’t found in your skin, the default will be used.



Till next time ;)

6
Top

Enjoyed this post?

Subscribe to our RSS Feed, Follow us on Twitter and spread it to your friends!

Author

Ivan Weiler

Team Leader

Ivan is a team leader and a senior web developer. He gained lots of experience managing some of the most complex Magento projects we had at Inchoo.

Other posts from this author

Discussion 6 Comments

Add Comment
  1. James

    The maintenance mode is plain stupid :) it won’t work , if included files (before flag check) have errors in them (like on time of transfer and so on)

    They should just do a mod_rewrite to a static file separated from general application code pool and have ip access rules like translation methods (to decide who see the maintenance and who gets the access to application

  2. I think this maintenance is not yet tested ever since, because when I try this process a couple of time, it didn’t work. In order to enable maintenance I just replaced the message in the admin and edit the css.

  3. I try it and yes maintenance work properly

  4. slide modification to index.php to make maintenance mode more useful.

    create a file called maintenance.php and add to it:

    
    

    then add/modify index.php so that the code at lines 56 on read something like:

    $maintenanceIPs = 'maintenance.php';
    if (file_exists($maintenanceFile)) {
    
    	if(file_exists($maintenanceIPs))
    	{
    		include_once $maintenanceIPs;
    		if (!in_array($_SERVER['REMOTE_ADDR'], $allowedIPs))
    		{
    			include_once dirname(__FILE__) . '/errors/503.php';
    		    exit;
    		}
    	}
    	else
    	{
    		include_once dirname(__FILE__) . '/errors/503.php';
    	    exit;
    	}
    
    }
    

    there may be better ways of doing this, but i’m keeping it short and simple

  5. Fernando

    Thanks for the tip! I have been looking everywhere for documentation on how to create a custom 503 page and this post is the only one that covers it! Thanks a lot!

  6. Ela

    Hi,

    I want to enable maintenance mode by having file called “maintenance.flag” and also how i can only able to reinstall it or doing some maintenance work in the live site, i know i can make it in admin mode but when i am going to upgrade or reinstalling it totally do i have the facility?

    Thanks

Add Your Comment

Please wrap all source codes with [code][/code] tags.
Top