Features in the Drupal 7 branch of Stage File Proxy are looking good, but I needed an up-to-date version to help me with my site upgrade. So I have back-ported most of the functionality of the current Drupal 7 module to Drupal 6, including the settings form (admin/settings/stage_file_proxy). I hope some will find this useful as they stage their old sites during migration to Drupal 7 and 8.

This patch is based on 6.x-1.x-dev.

Comments

thinkyhead created an issue. See original summary.

thinkyhead’s picture

StatusFileSize
new12.25 KB
thinkyhead’s picture

Title: More Features for D6 » Updated Patch, Enhanced!
StatusFileSize
new16.78 KB

Here's an updated patch that cleans up the code a bit and also does an extra trick for those cases where links are hard-coded to /sites/my.remote.site/files instead of /sites/my.local.site/files. Currently stage_file_proxy only redirects files within the local files path, thus these paths need to have been generated programmatically on the staging site. However, many sites have many hard-coded paths in their node content, as generated by WYSIWYG image uploaders. These paths will not point to the local files folder path, but the remote files folder path, which may differ via the settings form. So, this patch also adds code to redirect files in the original (remote) path.

thinkyhead’s picture

StatusFileSize
new17.01 KB

This patch further cleans up the code, and I've added a hook to fix paths as they are loaded from the "file" table as well, allowing cck filefield to be redirected.

/**
 * Implementation of hook_file_load().
 */
function stage_file_proxy_file_load(&$file) {
  $path = _stage_file_proxy_get_likely_file_path($file->filepath);
  if ($path !== FALSE) {
    $file->filepath = $path;
  }
}
thinkyhead’s picture

StatusFileSize
new17.01 KB

Oops, a patch without a typo...

thinkyhead’s picture

Title: Updated Patch, Enhanced! » Update D6 module with latest features
StatusFileSize
new17.94 KB

This patch adds some more code to additionally intercept the theming of imagefield_image, because that function calls field_file_urlencode_path which will prepend the local files path if the path doesn't contain it (as in the case of a different remote files path). Other modules that call field_file_urlencode_path have to be intercepted case-by-case, because there's no easy way to intercept field_file_urlencode_path.

thinkyhead’s picture

StatusFileSize
new18.33 KB

I keep finding more things needing a workaround in my setup. In this case I've added code so that swftools won't complain when a file doesn't exist locally. It simply sets the swftools_check_media setting to FALSE when stage_file_proxy is enabled. I thought of simply adding the following line to the init hook, but overriding options this way can be annoying to admins:


  $GLOBALS['conf']['swftools_check_media'] = FALSE;

asrob’s picture

Status: Active » Closed (won't fix)

I would close this issue because Drupal 6 reached EOL. See https://www.drupal.org/drupal-6-eol.