Skip to content

fix the exif_read_data issue - #36420

Merged
artonge merged 1 commit into
masterfrom
enh/34958/fix-exif-log
Jan 30, 2023
Merged

fix the exif_read_data issue#36420
artonge merged 1 commit into
masterfrom
enh/34958/fix-exif-log

Conversation

@szaimen

@szaimenszaimen commented Jan 28, 2023

Copy link
Copy Markdown
Contributor

@szaimenszaimen added the 2. developing Work in progress label Jan 28, 2023
@szaimenszaimen added this to the Nextcloud 26 milestone Jan 28, 2023
Comment threadlib/private/Metadata/Provider/ExifProvider.php Fixed
Comment threadlib/private/Metadata/Provider/ExifProvider.php Fixed
@szaimen
szaimenforce-pushed the enh/34958/fix-exif-log branch 2 times, most recently from d9c5383 to 5b4f201CompareJanuary 28, 2023 10:13
Comment threadlib/private/Metadata/Provider/ExifProvider.php Fixed
@szaimen
szaimenforce-pushed the enh/34958/fix-exif-log branch from 5b4f201 to 3fb06baCompareJanuary 28, 2023 10:20
Signed-off-by: Simon L <szaimen@e.mail.de>
Comment threadlib/private/Metadata/Provider/ExifProvider.php Fixed
Comment threadlib/private/Metadata/Provider/ExifProvider.php Fixed
@szaimen
szaimenforce-pushed the enh/34958/fix-exif-log branch from 3fb06ba to a704619CompareJanuary 28, 2023 10:24
@szaimenszaimen added bug 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jan 28, 2023
@szaimen
szaimen marked this pull request as ready for review January 28, 2023 10:26
// Revert right after reading the exif data.
$oldBufferSize = stream_set_chunk_size($fileDescriptor, 1);
$data = exif_read_data($fileDescriptor, 'ANY_TAG', true);
$data = @exif_read_data($fileDescriptor, 'ANY_TAG', true);

@szaimenszaimenJan 28, 2023

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was actually the only way how I could suppress the log message when testing with https://user-images.githubusercontent.com/12234510/205661916-3e7b14b4-6d4b-4dc2-9903-5265f95a2aee.png

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@szaimenszaimen changed the title try to fix the exif_read_data issueto fix the exif_read_data issueJan 28, 2023
@szaimen

Copy link
Copy Markdown
ContributorAuthor

/backport to stable25

@szaimenszaimen changed the title to fix the exif_read_data issuefix the exif_read_data issueJan 28, 2023
@simonspa

Copy link
Copy Markdown
Contributor

What I find odd is that this seems to be only triggered by Android client uploads, but not when adding the exact same file via web interface. In one case, the error is thrown, in the other case EXIF data is retrieved just fine - so I guess there is still something else going on.

Nevertheless, suppressing this error seems to make sense to me.

@artongeartonge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you understand why the try/catch is not enough ?
Not a fan of silencing error like that.
Maybe changing } catch (\Exception $ex) { for } catch (\Throwable $ex) { and changing log level to info would be enough ?

@come-nc

Copy link
Copy Markdown
Contributor

Do you understand why the try/catch is not enough ? Not a fan of silencing error like that. Maybe changing } catch (\Exception $ex) { for } catch (\Throwable $ex) { and changing log level to info would be enough ?

https://www.php.net/manual/function.exif-read-data.php states:

Errors of level E_WARNING and/or E_NOTICE may be raised for unsupported tags or other potential error conditions, but the function still tries to read all comprehensible information.

You cannot try/catch those errors, that goes straight to log.
The only way to catch them is to override the logger before the call, which is not practical.
From what I understand of the documentation, it does not throw because in some cases it still returns partial information.

@szaimen

Copy link
Copy Markdown
ContributorAuthor

Thanks @come-nc! So good to merge?

@artonge
artonge merged commit 3bfc5a4 into masterJan 30, 2023
@artonge
artonge deleted the enh/34958/fix-exif-log branch January 30, 2023 14:41
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Error: exif_read_data(): File not supported at /var/www/nextcloud/lib/private/Metadata/Provider/ExifProvider.php#59

6 participants

@szaimen@simonspa@come-nc@artonge@github-advanced-security@DrNanoLan89