In older versions of filefield_paths module, after fixing issue https://www.drupal.org/node/1361884 module checks file_uri_scheme for each file via:

 function filefield_paths_uri_is_local($uri) {
  $scheme = file_uri_scheme($uri);
  $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_LOCAL);
  return !empty($wrappers[$scheme]) && empty($wrappers[$scheme]['remote']);
} 

But in current version this function is replaced by other code that checks only field uri:

    $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE);
    foreach ($items as &$file) {
      $scheme = $field['settings']['uri_scheme'];
      if (!empty($wrappers[$scheme])) {

I use mixed media field that can contains local files and youtube video (via media_youtube). Current version of filefield_paths module checks only field settings, so it broke all youtube:// urls.

Please give back old version of uri scheme checking for each file, or provide any other solution for this problem.

Comments

Murz created an issue. See original summary.

murz’s picture

Good way may be replace string:

      $scheme = $field['settings']['uri_scheme'];

to

      $scheme = file_uri_scheme($file['uri']);

or this is not so good solution?

murz’s picture

Status: Active » Needs review
StatusFileSize
new694 bytes

This way fix problem on my sites, so I attach my patch, please review it.

deciphered’s picture

Status: Needs review » Needs work

No, that is not a good solution, as a normal file is uploaded to 'temporary://' before being processed, and this change will ensure that the file stays there, breaking all file uploads.

I'll do some testing ASAP to see if I can reproduce the issue and determine an appropriate fix.

murz’s picture

Thanks for the reply, how to reproduce:
1. Install modules: FileField paths, Media, File Entity, Media Youtube
2. Create new file field with Media Browser widget
3. Setup some "File path" and "File name" templates.
4. Attach to this field some local file, and Media Youtube object

You will see that FileField paths creates empty file on target path for "Media Youtube object", and break youtube:// uri for this file.

murz’s picture

Also I test my patch with Media Browser widget - it works normally, because Media Browser widget already do upload process and provide public:// path to field object.

But with default file widget seems that FileField paths got temporary:// url, so here may be the problem. But after test upload I see normal path for default file widget too, seems that FileField paths check paths double time - with temporary:// and after this - with public:// path.

erier’s picture

I'm having a similar issue where the updated 'temporary://' logic is causing fits.

The logs show this:

File temporary://filefield_paths/...file_path (/server/path/...) could not be copied because it does not exist.

We've reverted the module to it's previous version and everything is back to normal.

This is one of our go-to modules for asset organization/etc. Hope this can be fixed so we can upgrade again!

Thanks

dobe’s picture

Having same issue.

deciphered’s picture

Can I confirm all having this issue are using the Media Browser / Media Youtube?

  • Deciphered committed af39ebb on 7.x-1.x
    #2576547: Fixed issue with Media Youtube files being processed.
    
deciphered’s picture

Status: Needs work » Fixed

Ok, so in regards to the Youtube issue.... the module is taking a bit of a liberty in using a File field where it isn't actually storing a file in the system, and as such it's partially to blame for this behaviour. File (Field) Paths would be perfectly fine with it using the 'youtube://' file stream wrapper if the said stream wrapper was actually present... but it's not in this case.

As such, I have implemented a workaround similar to the above suggested, but in a way that respects the normal functionality of this module as well. Now it will check if the current (unprocessed) file lives in the 'temporary' or destination file stream wrapper before trying to process the file.

For anyone in this issue having problems with temporary:// but not in relation to Media Youtube, please provide details in #2582799: File Field Path save only to Temporary Directory

Status: Fixed » Closed (fixed)

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

Status: Closed (fixed) » Needs work

The last submitted patch, 3: filefield_paths_ignore_notwritable_uri_fix-2576547-1.patch, failed testing.

deciphered’s picture

Status: Needs work » Closed (fixed)