Professional Web Hosting since 2005
New!

Upgrading Magento

We’ve been asked how easy it is to upgrade Magento. So, there I was thinking, hey – they’ve got this Magento Connect Manager, a few clicks and we’re done. Wrong. Very wrong. Go on to read the tale of the dreaded “500 Internal Server Error” problem (= your permissions are wrong), a small issue with Url.php and why not taking backups is really bad for your health.

The upgrade test was carried out on a standard Magento v1.3.0 install on a Linux with PHP5.2.9. Note that Magento does not allow gradual upgrades, at least not via the Magento Connect Manager. If you use the Manager, it’s all or nothing.

Preparation

Never, ever upgrade on a live site unless you really fancy a nervous break-down. The route to sanity is:

  • a staging (test) environment, preferably on a separate domain to avoid all temptation of over-writing the wrong files
  • backups, backups, backups. Backups are like a life-vest – cumbersome until you really need them

Staging Environment: Upgrade

Assuming you’re safely on your test/staging copy, access Magento Connect Manager by going in your browser to the “yourmagentoshop”/downloader/ folder or log into your Magento admin and go to “System -> Magento Connect -> Magento Connect Manager”. Click “check for upgrades”. If nothing happens and/or no upgrades show, then you probably installed Magento without the PEAR downloader. In order to get upgrades via Magento Connect to work, you need to enter “magento-core/Mage_All_Latest ” in the extension key field. If at this stage all goes to pot, check my problem section below.

The Magento Knowledgebase says: It is possible that you will see no extensions in MagentoConnect Manager. This means that you have just uploaded the files without using PEAR downloader. In that case enter magento-core/Mage_All_Latest in the extension key field and click Install button. This will install all latest MagentoConnect core packages on top of existing files and will allow future upgrades through MagentoConnect. Source: www.magentocommerce.com/wiki/upgrading_magento

Magento Connect Manager


1. Click ‘Select all upgradable extensions’
2. Click ‘Commit changes’
3. Watch the console progress for error messages
4. After successfully upgrading click the ‘Refresh’ button that will appear under the console frame.

Check your customisations / templates

If you’ve come to this stage, it’s now a case of testing all your customisations to make sure they still work on the new version. I find scenarios a good help in this – have test routines such as purchasing, browsing etc which systematically test all key areas of your site.

Apply to live site

If you’ve tested, fixed anything that’s broken then you’re ready to apply to your live site. But only after you’ve taken that backup!

Problem #1 Magento Connect & Permissions

If you did not install Magento via the PEAR downloader, then you first have to run the command magento-core/Mage_All_Latest through Magento Connect. And this will screw up your file/folder permissions rendering your entire site as one big “500 Internal Server Error”.
Solution: Via the SSH client of your choice (e.g. Putty) run the following 2 commands:
find ./ -type f -exec chmod 644 {} \;
find ./ -type d -exec chmod 755 {} \;
Sources: http://www.magentocommerce.com/boards/viewthread/9188/P15/#t56614

UPDATE:
http://www.magentocommerce.com/wiki/groups/227/resetting_file_permissions is the Wiki page.

Putty

Problem #2 turnOffSecretKey(Array ( ) )

When I logged back into /downloader, all I got was: “Invalid method Mage_Adminhtml_Model_Url::turnOffSecretKey(Array ( ) )”.
Solution: You need to manually overwrite app/code/core/Mage/Adminhtml/Model/Url.php with the latest version
Sources: http://www.magentocommerce.com/boards/viewthread/38995/P15/#t127985

Problem #3: Still no packages in admin??

After solving problems #1 and #2 I felt on a roll. But hey, the version still said 1.3.0 in my admin. And the Connect Manager did not show a nice long list of stuff to update.
Solution: So I ran magento-core/Mage_All_Latest again and this time, I got a nice long list of stuff without any Internal Server Errors and the upgrade was applied.

Problem #4: Admin template / no drop-downs

But when I returned to admin, the drop-downs weren’t working, rendering the admin inaccessible to me.
Solution: I had to run the 2 SSH permission commands again. Although this time there was no “500 Internal Server Error”, the problem was the same – wrong file permissions.

Problem #5: Install error

During the install, I also encountered the error: “ERROR: failed to write /var/www/html/magento2/skin/adminhtml/default/default/.tmpboxes.css: Non-static method PEAR_Installer_Role::factory() should not be called statically, assuming $this from incompatible contex”.
Seems a bug in the code, so no solution for this.

Magento Connect Bug

Concerns

By running the upgrade via Magento Connect Manager I don’t know whether all files were successfully updated. The problem with the Url.php file was obvious, but a nagging doubt remains what other files were missed out without me knowing about it.

I’m also less than impressed that running an upgrade required solving 2 fatal errors, one of which rendered the entire site inaccessible and required SSH access to resolve (SSH access is standard on our hosting packages but some knowledge of command line will be required).

In summary, the upgrade experience confirms my belief that Magento is written for coders who don’t mind the odd command line, are happy to debug and have firm backup habits.

,

One Response to Upgrading Magento

  1. Kat February 3, 2010 at 9:41 am #

    If Magento is teaching me anything then that’s to backup, backup, backup.
    It takes me about half an hour to backup everything every time, but it’s worth it!! :-)

    Thanks for this great post!

    Just my experience, I used Mage_All_Latest through Magento Connect once and I never repeated that mistake again. It completely messed my system.

Leave a Reply