Migrate patch from http://drupal.org/node/131825 to 5.x