News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SMF 2.0.17 - Thumbnail file with 0/zero size created

Started by GL700Wing, September 17, 2020, 12:26:24 AM

Previous topic - Next topic

GL700Wing

In ./Sources/Subs-Graphics.php if the createThumbnail function does not successfully a thumbnail file it creates a zero size thumbnail file instead.

However, if a thumbnail is successfully created by the createThumbnail function it is subsequently renamed by the calling function (ie, createAttachment in ./Sources/Subs-Post.php or loadAttachmentContext in ./Sources/Display.php).

The name of the zero size thumbnail file is the the name of the source file plus the suffix '_thumb' (eg, source file = 186_2d634a9b058ca5f5fe3798a2ba9e6e7bc59ec790, zero size thumbnail file = 186_2d634a9b058ca5f5fe3798a2ba9e6e7bc59ec790_thumb). 

Quotefunction createThumbnail($source, $max_width, $max_height)
{
   global $modSettings;

   $destName = $source . '_thumb.tmp';

   // Do the actual resize.
   if (!empty($modSettings['attachment_thumb_png']))
      $success = resizeImageFile($source, $destName, $max_width, $max_height, 3);
   else
      $success = resizeImageFile($source, $destName, $max_width, $max_height);

   // Okay, we're done with the temporary stuff.
   $destName = substr($destName, 0, -4);

   if ($success && @rename($destName . '.tmp', $destName))
      return true;
   else
   {
      @unlink($destName . '.tmp');
      @touch($destName);
      return false;
   }
}

Also the zero size thumbnail file is not removed when the associated image attachment is deleted because information about the zero size thumbnail file was not added to the 'attachments' table.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Aleksi "Lex" Kilpinen

I've seen this happen - And this generally happens if the thumbnail creation fails unexpectedly, because of server limitations like memory limits.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

GL700Wing

Quote from: Aleksi "Lex" Kilpinen on September 17, 2020, 01:48:30 AM
I've seen this happen - And this generally happens if the thumbnail creation fails unexpectedly, because of server limitations like memory limits.
It's easily reproducible in the situation you describe - it doesn't make any sense to me that it even gets created and it bugs me having junk files that never get cleaned up in the attachments directory ...
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Advertisement: