When I first installed this module, my site started throwing a lot of database errors. In short, the file_aliases_preprocess_image_style() function, in line 49 of file_aliases.module tries to query the database for an empty "fid". At least on my Postgres server, this caused a nasty DB error.

Looking at the documentation of drupal_lookup_path, if an alias for that file does not exist, then it returns false. Therefore, I added a check for that false return, in which case it would not try to find an alias. This is my resulted function:

function file_aliases_preprocess_image_style(&$variables) {
  global $base_url;
  $source = drupal_lookup_path('source', str_replace($base_url . base_path(), '', $variables['path']));
  if ($source !== FALSE) {
    $fid = drupal_substr($source, 22);
    if ($uri = db_query("SELECT uri FROM {file_managed} WHERE fid = :fid", array(':fid' => $fid))->fetchField()) {
      $variables['path'] = $uri;
    }
  }
}

Comments

greg.1.anderson’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Priority: Normal » Major
Status: Active » Reviewed & tested by the community
StatusFileSize
new818 bytes

I second that. This module works great under mysql, but when I tried to use it with a postgresql db, I got db errors as described above, preventing all file uploads. The described fix also worked great for me.

I have attached it as a patch against the -dev branch.

neRok’s picture

I have made a patch to fix a bunch of issues with File Aliases module, including this issue, in the following issue.
#1896326: Combined patch for all known issues in D7 branch

deciphered’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Thanks, fixed and committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.