Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Developer's Quick Tip - Working with Memcache and File Uploads

Parent Feed: 

As a Drupal developer and recent memcache convert, I now know the joy of speedy caching.

Memcache actually comes with 2 modules: the main memcache code as well as "memcache admin" which, as far as I can tell, is really only necessary during devlopment and testing of the site (sort of the same way the Views UI module can be disabled after a site goes live).

When using Memcache with Drupal 5.x (it hasn't been ported to 6.x yet, but there is some ongoing work), there's a big "gotcha" that has gotten me on more than one occasion - the "show memcache statistics at the bottom of each page" option on admin/settings/memcache.

This works a lot like the devel module where it provides some useful stuff at the bottom of every page, but since it attaches itself to the bottom of every Drupal page load, it can mess with some AJAX and AHAH calls.

The upload module is one place where it can wreck havoc, pretty much causing any uploads to fail (endless-barber-pole-of-death style). Disabling the statistics or the entire "memcache admin" module returns things to normal.

In looking at the memcache_admin.module code, the problem is (relatively) easy to spot - in the memcache_admin_init() function, there are a couple of cases where the statistics aren't displayed: when the user is anonymous, on update.php, and during an autocomplete AJAX call. The devel_init() function by comparison, includes a bunch more exceptions where the statistics aren't displayed "upload/js" is one of them.

I've gone ahead and created an issue for this fix, hopefully it'll make it into the next release (and prevent me from any more head-smacking). In the meantime, if you're using memcache and file uploads are failing, this could be your solution.

Author: 
RSS Tags: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web