After upgrading from 6.x.1.6, to 6.x.1.7, all user profile pictures disappeared. dblog shows an "access denied" error. Reverting to 6.x.1.6 solved the problem.

Thank goodness for Drush and automated module backups!

Comments

sterndata’s picture

By the way, the site is running with a private file system, but all authenticated users have access to user profiles. Also, 6.x.1.6 is using CKEditor 3.6.1, while CKEditor 6.x.1.7 was using CKEditor 3.6.2.

jrhansen’s picture

I have the same issue, but I just didn't realize that it had something to do with CKEditor. All files uploaded with the PRIVATE:// scheme turned "missing", and I guess it is caused by this function in the ckeditor.module file at line 453:

function ckeditor_file_download($uri) {

  if ($path = file_create_url($uri)) {
    $result = db_query("SELECT f.* FROM {file_managed} f WHERE uri = :uri", array(':uri' => $path));
    foreach ($result as $record)
    {
      return NULL;
    }
    //No info in DB? Probably a file uploaded with FCKeditor / CKFinder
    $global_profile = ckeditor_profile_load("CKEditor Global Profile");
    //Assume that files inside of ckeditor directory belong to the CKEditor. If private directory is set, let the decision about protection to the user.
    $private_dir_db = $private_dir = isset($global_profile->settings['private_dir']) ? trim($global_profile->settings['private_dir'], '\/') : '';
    $private_dir_db = str_replace(array('\\%u', '\\%n'),array('', '') , $private_dir_db);
    $private_dir = preg_quote($private_dir, '#');
    $private_dir = strtr($private_dir, array('%u' => '(\d+)', '%n' => '([\x80-\xF7 \w@.-]+)')); // regex for %n taken from user_validate_name() in user.module
    $private_dir = trim($private_dir, '\/');

    $regex = '#^'. preg_quote(file_default_scheme() . '://' , '#') . $private_dir .'#';
    $path =   file_default_scheme() . '://' . str_replace(file_default_scheme() . '://', '' , $uri)   ;
    if (!$private_dir && variable_get('file_default_scheme', '') == 'private' && strcmp($global_profile->settings['ckeditor_allow_download_private_files'], 't') != 0) return -1;
    if (preg_match($regex, $path))
    {
      $info = image_get_info($uri);
      return array('Content-Type' => $info['mime_type']);
    }
  }
}

The "return NULL;" line looks weird. As I don't use the CKEditor for files, I just commented the entire function out, and disabled/enabled the CKEditor module. Now, the private files are working again.

However, I still have problems with uploading user pictures, but as far as I can see, they are stored as TEMPORARY files in the file_managed table, which must be another (core) bug. I just upgraded to Drupal 7.9, and I thought that this bug had been fixed. Oh well, that's another issue...

mkesicki’s picture

Status: Active » Closed (works as designed)

@jrhansen you wrote about drupal 7 and this ticket is for drupal 6.
return NULL in mentioned function is to pass file permissions to drupal and/or other modules.
It is how it should be.
In latest CKEditor module release (both for Drupal 6 & 7) there is new option "Enable access to files located in the private folder" in CKEditor "Global Profile" configuration (this option shows when private file system is set in drupal). When enabled CKEditor will serve all files from private file system. So this should works in this case. When this option is disabled CKEditor try check if user should have access to file.

EDIT:
Similar problem reported here : #1324990: [D7] Access to private file (download) problems

jzornig’s picture

Status: Closed (works as designed) » Active

I also have this problem. Upgrading from CKEditor 6.x-1.6 to either 1.7 or 1.8 causes all user profile pictures to become unaccessible even to the admin user.

mkesicki’s picture

Status: Active » Fixed

@jzornig please update to latest DEV version. There was a fix for #1343314: [D6] Change settings for private download. If you have more problems with DEV version please reopen this ticket.

jzornig’s picture

Thanks michal_cksource. The latest dev version does resolve the issue on my site.

Status: Fixed » Closed (fixed)

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