Skip to content

[3.0] Stop logging a warning for every attachment that is not a JPEG - #9480

Merged
live627 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/thumbnail-exif-warning
Aug 11, 2026
Merged

[3.0] Stop logging a warning for every attachment that is not a JPEG#9480
live627 merged 1 commit into
SimpleMachines:release-3.0from
albertlast:3.0/thumbnail-exif-warning

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Attaching a PNG to a post writes a row to smf_log_errors:

2: exif_thumbnail(7_ddfa4352…dat): File not supported
/index.php?action=uploadAttach;sa=add;…

Image::createThumbnail() calls exif_thumbnail($this->source) to find out whether the image already has an embedded thumbnail. Only JPEG and TIFF can carry one; for every other format the function raises E_WARNING and returns false, and SMF's error handler logs it. So every PNG, GIF or WebP attachment - and every avatar - leaves a warning behind for a completely ordinary upload.

The constructor already answered this question: checkForEmbeddedThumb() runs on load and sets $this->embedded_thumb, and it suppresses its own exif_read_data() call for precisely this reason. Reading the property removes the warning and a redundant second read of the file.

How to test

Attach a PNG to a post. Before: one general row per upload in smf_log_errors. After: none, and the thumbnail is still generated (smf_attachments gets its attachment_type = 3 row and the post shows a clickable thumb).

Issues References (Fixes|Related|Closes)

Found while sweeping the topic display for the #7933 split.

createThumbnail() asks exif_thumbnail() whether the image already carries
an embedded thumbnail. That function emits a warning for every format that
cannot hold one, so uploading a PNG - or a GIF, or a WebP - wrote a row to
the error log, at 2: exif_thumbnail(...): File not supported.

The constructor already answered the same question into $embedded_thumb,
and checkForEmbeddedThumb() silences its own call for exactly this reason.
Read the property instead of asking twice.

Signed-off-by: Mathias Papenbrock <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@albertlast albertlast mentioned this pull request Aug 9, 2026
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 6 milestone Aug 10, 2026
@live627
live627 merged commit 29e0e50 into SimpleMachines:release-3.0 Aug 11, 2026
4 checks passed
@jdarwood007 jdarwood007 modified the milestones: 3.0 Alpha 6, 3.0 Alpha 5 Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants