On line 527 of font-your-face.module the following line causes errors in some circumstances when because it attempts to save the $css variable into a file without checking to see if the $css variable is empty.

file_save_data($css, $destination, FILE_EXISTS_REPLACE);

The error that was showing up for me was as follows: "The selected file /sites/default/files/temp/fileIIA5VE could not be copied." (The filename changed on every pageload).

A back trace of the error showed that the file save operation was failing because the file was empty, yet the font-your-face module was attempting the operation on every page load leading to hundreds of empty files accumulating in the temp directory.

The code below fixes the issue.

if (!empty($css)) {
  file_save_data($css, $destination, FILE_EXISTS_REPLACE);
}

It seems too simple to really warrant making an actual patch.

Comments

sreynen’s picture

Status: Needs review » Needs work

I'm not clear on why you can't copy an empty file. Is there something special about empty files that prevents them from being copied? Are you sure this only happens when $css is empty?

If we don't write empty $css, you can never remove the last font from your CSS file, which seems like a problem. If writing empty files really doesn't work (which seems like a bug in Drupal), then we'd need to add logic to delete the file when it should be empty.

sreynen’s picture

Status: Needs work » Postponed (maintainer needs more info)

Need more info.

neslee canil pinto’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (outdated)