my blog_Drupal update nightmares

15.06.2010

Sometimes things go as planned, and sometimes they don't. That sentence sums up my relationship with Drupal. Tonight was one of the bad times. I just finished bringing my own site up to date with the latest Drupal security release (6.17 at the time of writing), and while I was at it I decided to update all my add-on modules to their latest versions too, because why not? While I was at THAT, I realized that I hadn't put my themes and modules in the right place when I built my site - they were sitting in the core "/themes" and "/modules" directories, which is baaaaaad) - so why not move them to the right place too?

So I did it all at once. But first, just to make sure the subsequent nightmare would be as annoying as possible, I overwrote my local versions of the modules with the new versions, then uploaded all the new ones to the right place on the webserver. Then I deleted the existing modules on the server.

No, since you ask, I didn't take a backup first. Why would I do that? It's only MY website. Some kind of brainfart caused me to skip every single one of the standard precautions I would take 100% of the time if I was altering a client's website. I didn't back up the database. I didn't back up the files. I didn't keep a local copy of the previous files. I just nuked everything and uploaded the new stuff, because at 3am sometimes I am an idiot.

Predictably, a lot of things went wrong. Allow me to list them.

  1. Conflicts with new module versions caused my site to crap out completely with PHP errors.
    • Fix: deleted a module I wasn't using anyway
  2. The modules and themes couldn't be found after I moved them from /modules to /sites/all/modules and from /themes to /sites/all/themes. Also, because the themes couldn't be found, I couldn't navigate to admin/settings/performance to clear the cache to fix this.
    • Fix: navigated to admin/build/modules which although themeless was still a functional form. Saving the modules page cleared the cache and the modules were picked up again.
  3. Lots of images in my theme didn't show up because I'd hard-coded the URLs in the stylesheet and the page templates and then moved the theme.
    • Fix: updated CSS files and content templates with the new image paths.
  4. Javascript gallery stopped working.
    • Fix: updated path to jQuery gallery in page.tpl.php
  5. My hacks were lost. This was a real pain. I'd forgotten that as a shortcut, I'd hacked the Flickr and Twitter modules to add some extra tags for style purposes. When I updated to the new module versions, I lost all my hacks. This really was no more than I deserved, since hacking modules is NOT THE DRUPAL WAY. All right, sometimes it's the quickest and easiest way to accomplish something in a hurry, and sometimes in the real world we are in a hurry, but sometimes we pay for our hurry, and in this case it cost me another hour.
    • Fix: wrote better CSS this time.

All this trouble taught me a couple of lessons which I thought I knew already, but apparently I needed to learn them again.

  1. Put your add-on modules and themes in sites/all/modules and sites/all/themes
  2. Don't hack core. Don't hack other peoples' modules - or if you absolutely must, don't forget that you've hacked them.
  3. Always take a backup before updating anything.
  4. Don't try to do anything important on a live server after 2am.

Like I said, I stick carefully to the guidelines when working on client sites but took shortcuts for my own, with a kind of mindset that it didn't matter because the only person who'd ever know was me anyway. So this is my confession to the world: I did not follow the Drupal Way, and for my penance I lost three hours of my life. I repent forevermore.

No tweets returned. This happens also when the username/password given is wrong. Please check them.

www.flickr.com/photos/alanpeart