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 😉


About Ivan Weiler

Technical Educator and Consultant

Ivan is a Technical Educator and Consultant. He gained lots of experience managing some of the most complex Magento projects we had at Inchoo.

Read more posts by Ivan / Visit Ivan's profile

6 comments

  1. 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

  2. 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!

  3. 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

  4. 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.

  5. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.